0
我正在加载一个下拉列表来选择场地,该值通过加载模态对话框。然后我得到以下错误。nil对象在rails 2.3中传递?
find_new
Showing app/views/layouts/_dia_venu_search.html.erb where line #5 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.map
Extracted source (around line #5):
2: <span style="text-align: right>
3:
4: <% form_tag "/calendar/dia_venue_view" do %>
5: <%= collection_select("venue", "venue_id", @venues , :id, :place, {:prompt => true}) %>
6: <%end%>
7: </span>
8: <span style="text-align: right">
Trace of template inclusion: app/views/layouts/_dia_venue_search.html.erb
RAILS_ROOT: D:/final2011_10_13
Application Trace | Framework Trace | Full Trace
C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/form_options_helper.rb:327:in `options_from_collection_for_select'
C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/form_options_helper.rb:543:in `to_collection_select_tag'
C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/form_options_helper.rb:162:in `collection_select'
D:/final2011_10_13/app/views/layouts/_dia_venu_search.html.erb:5:in `_run_erb_app47views47layouts47_dia_venu_search46html46erb_locals_dia_venu_search_object'
D:/final2011_10_13/app/views/layouts/_dia_venu_search.html.erb:4:in `_run_erb_app47views47layouts47_dia_venu_search46html46erb_locals_dia_venu_search_object'
D:/final2011_10_13/app/views/layouts/_dia_venue_search.html.erb:15:in `_run_erb_app47views47layouts47_dia_venue_search46html46erb_locals_dia_venue_search_object'
D:/final2011_10_13/app/views/layouts/_dia_venue_search.html.erb:2:in `_run_erb_app47views47layouts47_dia_venue_search46html46erb_locals_dia_venue_search_object'
D:/final2011_10_13/app/controllers/events_controller.rb:196:in `find_new'
这里是我的_dia_venu_search.html.erb代码:
<span style="text-align: right">
<span style="text-align: right>
<% form_tag "/calendar/dia_venue_view" do %>
<%= collection_select("venue", "venue_id", @venues , :id, :place, {:prompt => true}) %>
<%end%>
</span>
<span style="text-align: right">
<%= submit_tag "search" %>
</span>
</span>
为什么我得到这个错误?有谁能够帮助我?
现在我没有收到任何错误。但它没有得到下拉列表的位置...... :( – Rosh
尝试放置一个调试器并检查@venues正在返回。 – Mahesh