Rails accepted_nested_attributes_for错误,请帮我发现它

我一直在尝试遵循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: Telephone(#80827590) expected, got Hash(#72886250)

你能帮我看看错误吗? 我应该在contact_controller.rb包含任何代码吗?

我使用以下代码:

 params = { :contact => { :name => 'Joe', :permanentcomment => "No Comment", :telephones_attributes => [ {:telephone => '787445741'}, {:telephone => '478589658'} ] }} Contact.create(params[:contact]) 

我将错误的参数传递给Contact.create控制器……