accessible under Rails 4 strong parameters transition?
I have a Rails 4 app and I currently use the protected_attributes
gem. It works fine but now I feel I need to transition to strong parameters. So the thing is I don't want to remove "attr_accessible" before all my tests pass. I tried to remove the "protected_attributes" in my gemfile and then I got this error: " 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."
I want to just ignore this error until all my tests pass how should I do that?
As sevenseacat points out, you should comment out all attr_accessible calls in all your classes. Yes, or your tests will break now, but that is actually a good thing. If all your tests were green and turn red now, you know exactly on which controllers you should add strong parameters. Seems to me the whole point of the red -> green cycle.
So please, let your tests fail and use the commented out attr_accessible calls as a reference for which attributes to require and permit in the corresponding controllers. As long as you don't make other changes you should not worry about breaking your test suite. You know what needs to be done to fix it.
链接地址: http://www.djcxy.com/p/35996.html上一篇: 受保护的Rails 4
下一篇: 在Rails 4下可访问强大的参数转换?