2012-08-13 4 views
0

선택 태그가있는 성별 모델을 표시하려고합니다. 여기 내 모델레일 선택 태그

Customer  Gender 
ID    Id 
First   Customer_id 
Last   description 
Email 
Password 

Customer 
    has_one :gender 
Gender 
    belongs_to :customer 

은 여기 내 선택 태그

<%= collection_select(:gender, :id, Gender.all, :id, :description) %> 

를 ATM하지만 나에게 다음과 같은 오류를 보여주는 대신

NoMethodError in Customers#edit 

Showing /home/jean/rail/map/app/views/customers/_general.html.erb where line #23 raised: 

undefined method `id' for []:Array 
Extracted source (around line #23): 

20:  
21:  <%= #collection_select(:gender, :description, @genders, :id, :description) 
22:  %> 
23:  <%= collection_select(:gender, :id, Gender.all, :id, :description) %> 
24: 
25:  <div class="customer_edit_name"> 
26:    <%= f.label "Birthday" %> 

답변

1

나는 당신이 성별의 체크 박스를 추가하려고 희망 고객 양식. 그렇다면 그것은해야

collection_select로 (: 고객 : gender_id, Gender.all : 아이디, : 설명)