【发布时间】:2011-03-24 12:45:57
【问题描述】:
NoMethodError in Points#create
Showing /Volumes/EXTERNAL/Proiecte/Roadie/app/views/points/_form.html.erb where line #20 raised:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.collect
Extracted source (around line #20):
17: </div>
18: <div class="field">
19: <%= f.label :section %><br />
20: <%= f.select(:section_id, [["Select a Section name", 0]] + @sections.collect {|p| [ p.name, p.id ] }) %>
21: </div>
22:
23: <div class="field">
基本上这里发生的情况是,当此表单页面中的其他字段之一(由模型验证)丢失时,rails 会吐出上面发布的错误。
一个部分有很多点,当创建一个新点时,用户应该能够选择一个父部分。
谁能解释为什么会这样?
【问题讨论】:
标签: ruby-on-rails view erb