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