mardi 10 mai 2016

How do I resolve mass assignment warnings in Rails 3.2.22 if I'm using strong_parameters?

I while ago, I migrated my app over to use strong_parameters, in the hope that this would improve security by making whitelisting of permitted parameters more explicit. It also allowed me to move this logic to the controller, where it made more sense to me because only the controller knew things like who was currently logged in, which affected which attributes were permitted.

Now I update to Rails 3.2.22.2, and I see thousands of warnings of this sort when running unit tests:

.../sanitizer.rb:11: warning: copying extra states: {"nested"=>true, "count"=>" 3 "}
.../sanitizer.rb:11: warning: following states will not be copied in the future version:
.../sanitizer.rb:11: warning:   subclass: ActiveSupport::HashWithIndifferentAccess

It seems like the way to resolve this sort of thing is usually to use attr_accessible on all models, but in this case I already removed it from all models deliberately when I switched to strong_parameters. Was this not what I was supposed to do?

Aucun commentaire:

Enregistrer un commentaire