Ruby on rails 嵌套属性/表单:不允许的参数

Ruby on rails 嵌套属性/表单:不允许的参数,ruby-on-rails,parameters,nested-forms,nested-attributes,Ruby On Rails,Parameters,Nested Forms,Nested Attributes,我已经看过了,但一定是遗漏了什么,因为我的日志告诉我所有权和图像仍然不被允许: User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]] Unpermitted parameters: ownership, image 我的嵌套表单_用于3个模型: = form_for @murals do |f| = f.fields_for @ownershi

我已经看过了,但一定是遗漏了什么,因为我的日志告诉我所有权和图像仍然不被允许:

User Load (0.3ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
    Unpermitted parameters: ownership, image 
我的嵌套表单_用于3个模型:

= form_for @murals do |f|

  = f.fields_for @ownerships do |owner|
    = owner.label "Artist"
    = owner.collection_select(:user_id, User.where(artist: true), :id, :first_name, { include_blank: "Pick an artist" })

  = f.hidden_field :latitude, id: 'lat'
  = f.hidden_field :longitude, id: 'long'

  = f.fields_for @images do |image|
    = image.label :file, 'Add Image'
    = image.file_field :file
    = image.file_field :file_cache, class: 'hidden'

  =f.submit 'Upload Mural', class: 'btn btn-primary upload-btn'
我的控制器(我刚刚用一个x
\u属性尝试了它:[:xyz]
,但运气不好)

Image.rb:

class Image < ActiveRecord::Base
  belongs_to :user
  belongs_to :mural

  mount_uploader :image, MuralUploader
end
类映像
所有权.rb

class Ownership < ActiveRecord::Base
  belongs_to :user
  belongs_to :mural
end
类所有权
User.rb:

class User < ActiveRecord::Base
  has_many :authentications, dependent: :destroy
  has_many :images
  has_many :ownerships
  has_many :murals, through: :ownerships

  validates :first_name, presence: true

  mount_uploader :avatar, AvatarUploader
end
class用户
Mural.rb:

class Mural < ActiveRecord::Base
  has_many :ownerships
  has_many :images
  has_many :users, through: :ownership
  accepts_nested_attributes_for :ownerships, :images
end
class壁画
您需要使用
接受
的嵌套属性来启用嵌套属性更新

class Mural < ActiveRecord::Base
  ...
  accepts_nested_attributes_for :images, :ownerships
  ...
end
class壁画

有关更多详细信息,请参阅。

您可以共享您的模型代码吗?看起来您的所有者协会有很多,如果是这样,请使用
所有者属性:[:user\u id]
@tyamagu2添加了它们。@mintuhouse无法实现它们的多元化。如果是这样,也无法获得它们的许可。
class Mural < ActiveRecord::Base
  ...
  accepts_nested_attributes_for :images, :ownerships
  ...
end