0
我试图通过将以下内容传递给create
来创建Gallery模型及其has_many
关联。Rails - 创建模型及其嵌套资源
[
{
"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
该死。这是我以前的事。非常感谢。 – Undistraction 2013-05-12 18:25:35