我正在尝试has_many
通过将以下内容传递给create
.
[
{
"title":"Some Titler",
"description":"",
"date":"18-3-2012",
"photographs":[
{
"title": "Some Title",
"camera": "Canon 600D"
},
{
"title": "Some Other Title",
"camera": "Canon 600D"
}
]
}
]
没有嵌套photographs
数组,它可以正常工作,但是有了它,我得到一个错误:
Photograph(#70242279271180) expected, got Hash(#70242248401160)
语法有什么问题?
class Gallery < ActiveRecord::Base
attr_accessible :date, :description, :published, :title
has_many :photographs
accepts_nested_attributes_for :photographs
end