更新时间:2023-11-24 10:41:04
To submit a form and it's associated children you need to use accepts_nested_attributes_for
为此,您需要在要使用的控制器的模型上对其进行声明(在您的情况下,它看起来像是Quote Controller.
To do this, you need to declare it at the model for the controller you are going to use (in your case, it looks like the Quote Controller.
class Quote < ActiveRecord::Base
attr_accessible :quote_number
has_one :customer
has_one :item
accepts_nested_attributes_for :customers, :items
end
此外,您需要确保声明可以访问的属性 您可以避免其他批量分配错误.
Also, you need to make sure you declare which attributes are accessible so you avoid other mass assignment errors.