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


Xander Miller
Xander Miller
9,072 Points

Devise gem behavior changed in rails 4.0

I've been going through the Rails tutorial but using Rails 4 and Ruby 2. So far everything has worked up to the editing Devise Views lesson in the User Authentication badge.

The attr_accessible method is no longer in the user.rb model. And If I try to added it, rails throws a fit.

The new first_name, last_name and prorile_name variables all seem to be mass editable without adding them to attr_accessible. It's sort of funny because during that segment Jason is going on about how important attr_accessible control is for app security. Does Rails 4 use something different that attr_accessible?

Just read on Stack Overflow that the Ruby method attr_accessor and the Rails method attr_accessible are functionally different. Learn something new every minute on treehouse.

1 Answer

Rails 4 current moved all the attr_accessible fields usage to the controller; user.rb refers to the model; if you downgrade to Rails 3, the treehouse tutorials will work otherwise you can use this work around listed on the devise README: https://github.com/plataformatec/devise#strong-parameters

Xander Miller
Xander Miller
9,072 Points

Thanks for the info! I'll try to follow the directions on the link you provided and make it work on Rails 4, I will have to learn sometime.