-2

您好,我尝试attr_protected在 Rails 4 上使用,但我不能。据说attr_protected是从 Rails 中提取到一个 gem 中。请为 params(strong_parameters) 使用新的推荐保护模型或添加protected_attributes到您的 Gemfile 以使用旧的保护模型。

我能知道什么?

attr_protected :project_id
4

2 回答 2

3

你真的应该考虑使用强参数。否则,您稍后会在批量分配规则中遇到麻烦。

但是,如果您坚持,请将其添加到您的Gemfile

gem "protected_attributes", "~> 1.0.7"

并运行捆绑器:

bundle install
于 2014-03-20T10:16:26.693 回答
0

开始使用强参数(推荐)或按照建议移回受保护的属性

于 2014-03-20T10:18:53.983 回答