Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

Generating a User Model

When I try to enter in my email address, password, and password confirmation, the site gives me the folowing:

ActiveModel::MassAssignmentSecurity::Error in Devise::RegistrationsController#create

Can anyone tell me what's going on?

2 Answers

I believe you have to go under Models > user.rb and before the "end" put the following --->

attr_accessible :email, :password, :password_confirmation

and if you get any other errors like that just go back and add the new part to the end. For instance, if the "remember me" tab is giving you errors. It would now look like this

attr_accessible :email, :password, :password_confirmation, :remember_me

David Woody
David Woody
8,671 Points

This worked for me. Thanks!

Every attribute sent to the model for save needs to be whitelisted for security reasons, so as @Zachary said you add it to attr_accessible, then it becomes whitelisted, you then repeat this for every new attribute.