Posts Tagged ‘RoR’


hi, few days back when i was learning on RoR , then while entering data into database i came across this problem ”
MassAssignmentSecurity::Error: Can’t mass-assign protected attributes”.

Though this is not a big task to deal with, but for any beginner like me, its a big thing to resolve. Here are the tricks on how to solve this, i tried several different ways to solve this.

1. First i tried commenting few lines in config>environments>development.rbĀ 

i commented this line,

config.active_record.mass_assignment_sanitizer = :strict

but this didn’t worked for me, and then i googled this problem and got solution from someones answer at stack overflow, this process was making change in certain piece of code, so here is the another process.

2. Goto following file config>application.rb and find the following line of code

config.active_record.whitelist_attributes = true

and set it to false like this

config.active_record.whitelist_attributes = false

and thats it, you are done.
For more updates and such new code tricks visit codeios.net