0
我想用選擇標籤顯示性別模型。在這裏我的模型Rails選擇標籤
Customer Gender
ID Id
First Customer_id
Last description
Email
Password
Customer
has_one :gender
Gender
belongs_to :customer
這裏我選擇標記的ATM
<%= collection_select(:gender, :id, Gender.all, :id, :description) %>
但它顯示我下面的錯誤,而不是
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" %>