Ruby on rails 3.2 Can';t mass assign protected attributes:post_id
我一直在尝试为我的ROR3网站创建一个类似的按钮。我使用了此链接中建议的解决方案: 我有一个用户,帖子和喜欢的模型。但是like按钮部分显示了我的show posts页面中的“不能批量分配受保护的属性:post_id”错误。我已经研究了其他线程的解决方案,但似乎没有任何工作。粘贴我的代码摘要以供参考Ruby on rails 3.2 Can';t mass assign protected attributes:post_id,ruby-on-rails-3.2,Ruby On Rails 3.2,我一直在尝试为我的ROR3网站创建一个类似的按钮。我使用了此链接中建议的解决方案: 我有一个用户,帖子和喜欢的模型。但是like按钮部分显示了我的show posts页面中的“不能批量分配受保护的属性:post_id”错误。我已经研究了其他线程的解决方案,但似乎没有任何工作。粘贴我的代码摘要以供参考 class Like < ActiveRecord::Base belongs_to :user belongs_to :post end class Post < Activ
class Like < ActiveRecord::Base
belongs_to :user
belongs_to :post
end
class Post < ActiveRecord::Base
attr_accessible :title, :content, :posts_attributes
belongs_to :user
has_many :likes
accepts_nested_attributes_for :likes
.
.
.
end
class User < ActiveRecord::Base
attr_accessible :email, :name, :password, :password_confirmation
has_many :posts, dependent: :destroy
has_many :likes
.
.
.
end
类类似于
提前感谢。将attr\u accessible:post\u id,:user\u id添加到您的同类车型中将attr\u accessible:post\u id,:user\u id添加到您的同类车型中很高兴听到这个消息!你能帮我一个忙,选择我的答案作为最终答案吗?很高兴听到!你能帮我一个忙,选择我的答案作为最终答案吗?