rails / protected_attributes

Protect attributes from mass-assignment in ActiveRecord models.
MIT License
228 stars 92 forks source link

regression: attr_accessible is added to all models #59

Closed josh-m-sharpe closed 9 years ago

josh-m-sharpe commented 9 years ago

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?

josh-m-sharpe commented 9 years ago

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

class ProtectedAttributes::Railtie def initializers_for [] end end

rafaelfranca commented 9 years ago

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

josh-m-sharpe commented 9 years ago

@rafaelfranca yes :/

rafaelfranca commented 9 years ago

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