新手问题 练习 rails101s 的时候遇到一个问题

dandan · 2015年07月03日 · 最后由 zoker 回复于 2015年07月03日 · 1900 次阅读

ActionView::Template::Error (undefined method model_name' for nil:NilClass): 1: <div class="col-md-4 col-md-offset-4"> 2: <h1>create</h1> 3: 4: <%= simple_form_for @group do |f| %> 5: <div class="form-group"> 6: <%= f.input :title, input_html: { class: "form-control"} %> 7: <%= f.input :description, input_html: { class: "form-control"} %> app/views/groups/new.html.erb:4:inapp_views_groups_new_html_erb__528623746075205267_70173123584560'

这里的 undef method 是什么问题呢?

@group 是 nil。

#1 楼 @rei 我该怎么解决呢?

in your groups_controller.rb

def new
  @group = Group.new
end

#3 楼 @zoker 原来多了一个 s ⊙﹏⊙b 汗

#4 楼 @dandan 什么多了一个 s

#5 楼 @zoker def new @groups = Group.new end

#6 楼 @dandan 这不是一个好问题,错误没格式化,没贴出相关action代码 etc. 建议看看这个帖子

需要 登录 后方可回复, 如果你还没有账号请 注册新账号