2011-10-14 3 views
0

장소를 선택하기 위해 드롭 다운 목록을로드 중입니다. 그 값은 모달 대화 상자를로드하는 데 사용됩니다. 그런 다음 오류가 발생했습니다. 레일에서 객체가 전달되지 않습니다. 2.3?

<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> 

가 왜이 오류가 않았다

: 여기
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 코드? 아무도 도와 줄 수 있니?

답변

0

귀하의 @venues는 nil을 반환합니다. collection_select는 배열을 필요로합니다. 시도해보기

<% @venues = [] unless @venues %> 
<%= collection_select("venue", "venue_id", @venues , :id, :place, {:prompt => true}) %> 
+0

오류가 발생하지 않았습니다. 하지만 드롭 다운 목록에 장소를 얻지 못했습니다 : ... ( – Rosh

+0

디버거를 넣고 @venues가 반환하는지 확인하십시오. – Mahesh

0

@venues의 값을 확인하십시오. 그것? 콜렉션 _ 선택이 해당 오류를 발생시킬 수 있습니다.

관련 문제