ruby-on-rails – 升级到Rails 4时,批量分配失败
发布时间:2020-12-16 23:14:53 所属栏目:百科 来源:网络整理
导读:deprecated_mass_assignment_security.rb:17:in `attr_accessible': `attr_accessible` is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add `protected_attributes` to your Gemfile
deprecated_mass_assignment_security.rb:17:in `attr_accessible': `attr_accessible` is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add `protected_attributes` to your Gemfile to use old one. (RuntimeError) 我尝试了消息所说的内容,将gem“strong_parameters”添加到我的Gemfile中. 但是当我做rails时,我得到了上面的错误. 更新 我试过了: config.active_record.whitelist_attributes = true 在confgi / application.rb中,也是假的,但实际上我不明白那个选项. 解决方法
在你的Gemfile中你会注意到gem’en protected_attributes’已经被删除了.
删除哈希. 运行捆绑安装. 但是由于protected_attributes已被弃用并且将来可能会消失,请使用上面帖子中提到的strong_parameters. 有关strong_parameters的更多信息,请参阅此link. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |