rails / protected_attributes

Protect attributes from mass-assignment in ActiveRecord models.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

regression: attr_accessible is added to all models

josh-m-sharpe opened this issue · comments

Isn't this a regression?

https://github.com/rails/protected_attributes/blob/master/lib/protected_attributes/railtie.rb#L10-L15

In rails 3 attr_accessible was not added to all models, but with this gem, in rails 4, it is... Sure, this might be a "Best practice" but I thought this gem was supposed to be a kludge to keep the same behavior that was supported in rails 3 around in rails 4 - which helps support the upgrade path.

Now, with this gem, that behavior has changed. So updating a legacy rails 3 app to rails 4 forces breaking changes.

Should this new behavior be configurable?

For anyone interested, I 'fixed' this issue by adding this in an initializer:

class ProtectedAttributes::Railtie
def initializers_for
[]
end
end

Can't you just set config.active_record.whitelist_attributes to false in your application?

The default is true since some patch version of 3.2, this gem is just using the same default.