0
我有兩個型號:問題在數據庫中使用collection_select儲存價值
Project.rb
class Project < ActiveRecord::Base
belongs_to :customer
end
和Customer.rb
class Customer < ActiveRecord::Base
has_many :projects
end
裏面的_form.html.erb我有:
<p>
<label>Select Customer</label>
<%= f.collection_select :customer_id, Customer.all, :id, :name, :include_blank => true %>
</p>
Whic h應該從客戶模型中收集客戶並顯示所有客戶,最後應將值分配給項目表中的customer_id。
現在,當我檢查日誌時,一切都在傳遞。當我選擇value = 1的第一個客戶時,它會在我的日誌中傳遞customer_id =「1」,但它不會存儲在表中。它在項目表中顯示customer_id = nil。
有人可以幫忙。謝謝:)
你是男人:)謝謝你這麼多桑托斯 – Supersonic