我一直在努力追随
Active Record Nested Attributes Guide,没有太大的成功.
我有以下型号:
class Contact < ActiveRecord::Base has_many :telephones accepts_nested_attributes_for :telephones end class Telephone < ActiveRecord::Base belongs_to :contact end
在尝试创建联系人时:
contact = { :name => "John",:telephones => [ {:telephone => '787445741'},{:telephone => '478589658'} ] } Contact.create(contact)
我收到以下错误:
ActiveRecord :: AssociationTypeMismatch:电话(#80827590)预计,得到哈希(#72886250)