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 the Devise Views Error

Hi,

I attempted to update the app/models/user.rb file. The user.rb file did not contain the following code which I added:

Setup accessible (or protected) attributes for your model

attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :profile_name # attr_accessible :title, :body

I then received the following error in my browser:

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 (around line #8): 6 7 8 9 10 11

# Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :profile_name # attr_accessible :title, :body
end

Application Trace | Framework Trace | Full Trace app/models/user.rb:8:in <class:User>' app/models/user.rb:1:in<top (required)>' config/routes.rb:2:in block in <top (required)>' config/routes.rb:1:in<top (required)>'

I am stuck on what is meant by using the protection model or adding the 'protected_attributes' to the Gemfile.

Any ideas?

3 Answers

Hi Daniel - thanks, yes I'm using Rails 4.0.0

Daniel Terreros
PLUS
Daniel Terreros
Courses Plus Student 6,178 Points

attr_accessible is no longer used in rails 4.

Strong Parameters for rails 4 is not covered in a video, here is a thread I'm in with two ways of doing it

You can check my code out at VanDanny on github. (The project name is BUZZ KC).