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

Brent Sullivan
Brent Sullivan
9,877 Points

attr_accessible ...I am adding :first_name, :last_name, :profile_name ...but it wrecks the project so far. Any ideas?

Here is my code:

class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable

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

end

Here is the error showing up in the browser when I try to refresh:

RuntimeError 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.

Extracted source:

:recoverable, :rememberable, :trackable, :validatable

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

2 Answers

Jimmy Hsu
Jimmy Hsu
6,511 Points

On a quick glance, what I see is a backwards compatibility issue with previous versions of Rails. Likely, in a new update (Rails 4?) "strong_parameters" are the way to go. I did a quick google, and this came up: https://github.com/rails/strong_parameters

For a quick fix, the latter part suggested to just add gem 'protected_attributes' to your Gemfile.