Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Simple Ruby on Rails Application Creating an Authentication System Generating the Devise Views

2 errors prohibited this user from being saved: Email can't be blank Password can't be blank

I got this error today while trying to fill up the sign up form which was built using devise.

2 Answers

i'm guessing you are talking about app/models/user.rb file. you don't need to have attr_accessible followed by attributes there no more if you are using Rails 4. in fact, if you type in the attributes, you'll get this error message:

attr_accessible is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add protected_attributes to your Gemfile to use old one.

basically, define a private method in the controller that takes the params hash. see an example here: https://github.com/rails/strong_parameters

So after searching a lot i realised that the .rb files that were being generated in the project were missing this. (probably only in the present latest version of rails)

attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :profile_name

So basically these have to be manually added by us which is quite tedious. Is there any workaround?