0

我正在尝试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
4

1 回答 1

1

改变

 "photographs":[]

 "photographs_attributes":[]
于 2013-05-12T17:49:45.250 回答