问题描述
我收到错误消息警告:无法批量分配受保护的属性有一个方法强参数可以解决问题"但是失败了我不想在每个模型中都做 attr_accessible :title, :description
,我宁愿使用 Strong 参数我在代码中使用group_params"方法来编辑/新建模型这里我的代码 https://gist.github.com/poc7667/5993437#file-group_controller
I got the error message WARNING: Can't mass-assign protected attributes forThere is a method "Strong parameter can solve the problem" but failedI don't want to do attr_accessible :title, :description
in every Model,I'd rather use the Strong parameterI use the 'group_params' method in the code , to edit/new modelHere my code https://gist.github.com/poc7667/5993437#file-group_controller
下面是我的宝石清单我使用的一些 gem 可能有隐藏的问题?
And below are my gem listI use some gems may have hidden problems ?
设计simple_form
devise simple_form
先谢谢大家^_^
Gems included by the bundle:
* actionmailer (4.0.0)
* actionpack (4.0.0)
* activemodel (4.0.0)
* activerecord (4.0.0)
* activerecord-deprecated_finders (1.0.3)
* activesupport (4.0.0)
* arel (4.0.0)
* atomic (1.1.10)
* bcrypt-ruby (3.1.1)
* builder (3.1.4)
* bundler (1.3.5)
* coffee-rails (4.0.0)
* coffee-script (2.2.0)
* coffee-script-source (1.6.3)
* devise (3.0.0.rc)
* erubis (2.7.0)
* execjs (1.4.0)
* hike (1.2.3)
* i18n (0.6.4)
* jbuilder (1.4.2)
* jquery-rails (3.0.4)
* json (1.8.0)
* mail (2.5.4)
* mime-types (1.23)
* minitest (4.7.5)
* multi_json (1.7.7)
* orm_adapter (0.4.0)
* polyglot (0.3.3)
* protected_attributes (1.0.2)
* rack (1.5.2)
* rack-test (0.6.2)
* rails (4.0.0)
* railties (4.0.0)
* rake (10.1.0)
* rdoc (3.12.2)
* sass (3.2.9)
* sass-rails (4.0.0)
* sdoc (0.3.20)
* simple_form (3.0.0.rc)
* sprockets (2.10.0)
* sprockets-rails (2.0.0)
* sqlite3 (1.3.7)
* thor (0.18.1)
* thread_safe (0.1.0)
* tilt (1.4.1)
* treetop (1.4.14)
* turbolinks (1.3.0)
* tzinfo (0.3.37)
* uglifier (2.1.2)
* warden (1.2.2)
推荐答案
你有一颗宝石
protected_attributes (1.0.2)
(Github)
为您的模型添加了旧的 attr_accessible 批量赋值保护.
Which adds the old attr_accessible mass-assignment protection to your models.
这篇关于在 Rail 4 中批量分配受保护的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!