Search code examples
ruby-on-railsmass-assignment

Getting mass-assignment warning in rails 3.1.8, but no attr_accessible called


I have a standalone app that runs on Rails 3.0.7, that is also used as a rails engine, which is run under rails 3.1.8 from the parent app. Now, I have a registration form which connects to a user model, has validations and so forth. When I was running the app as an engine, and I would try to register, I could see in the logs a "cannot mass-assign attributes" warning.

My user.rb model file has no calls to attr_accessible or attr_protected. Adding a call to attr_accessible for the given fields on that model fixed the issue. However, I am wondering what might be causing it. When I run the app as standalone, it works fine. I'm not sure if the rails version has anything to do with it, but it's an important difference to note.


Solution

  • check if parent projects config/environments/x.rb file has config.active_record.mass_assignment_sanitizer = :strict, if so commenting it may work but not advisable