I try to follow the Active Record Nested Attributes Guide without much success.
I have the following models:
class Contact < ActiveRecord::Base has_many :telephones accepts_nested_attributes_for :telephones end class Telephone < ActiveRecord::Base belongs_to :contact end
When trying to create a contact:
contact = { :name => "John", :telephones => [ {:telephone => '787445741'}, {:telephone => '478589658'} ] } Contact.create(contact)
I get the following error: ActiveRecord::AssociationTypeMismatch: Telephone(#80827590) expected, got Hash(#72886250)
Could you help me find a bug? Is there any code that I should include in contact_controller.rb ?
ruby-on-rails activerecord
jfanals
source share