Ruby on rails 无效关联。确保接受\u嵌套的\u属性\u用于:照片关联

Ruby on rails 无效关联。确保接受\u嵌套的\u属性\u用于:照片关联,ruby-on-rails,paperclip,nested-forms,Ruby On Rails,Paperclip,Nested Forms,我正在为一个模型实现多张照片上传,因此我使用了回形针和嵌套形式的gems 一个酒店有很多照片 这是属性模型 class Property < ActiveRecord::Base attr_accessible :photos_attributes, :type, :price, :address, :desc, :category_id, :location_id, :user_id TYPE = { rent: "rent", sale: "sale" }

我正在为一个模型实现多张照片上传,因此我使用了回形针和嵌套形式的gems

一个酒店有很多照片

这是属性模型

class Property < ActiveRecord::Base
  attr_accessible :photos_attributes, :type, :price, :address, :desc, :category_id, :location_id, :user_id
  TYPE = {
    rent: "rent",
    sale: "sale"
  }

  has_many :photos, dependent: :destroy
  belongs_to :category
  belongs_to :location
  belongs_to :user
  accepts_nested_attributes_for :photos, reject_if: lambda { |t| t[:photo].nil? }, allow_destroy: true
  acts_as_taggable
end
错误是
无效关联。确保接受的\u嵌套的\u属性\u用于:照片关联。

当我在控制台上运行
Property.new.attributes.keys
时,它不会将
:photos\u attributes
显示为键。它显示
[“id”、“type”、“price”、“address”、“desc”、“created\u at”、“updated\u at”、“category\u id”、“location\u id”、“user\u id”]


我卡住了。

尝试更改一行,该行会导致以下错误:

= f.link_to_add "Add", :photos

尝试更改导致以下错误的行:

= f.link_to_add "Add", :photos
= f.link_to_add "Add", :photos