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

Lee Hughes
Lee Hughes
8,380 Points

Generating the Devise Views (Rails 4.0) attr_accessible

I'm going through the video

http://teamtreehouse.com/library/build-a-simple-ruby-on-rails-application/creating-an-authentication-system/generating-the-devise-views

Jason says to use the following code for the error to stop working.

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

However, I'm using Rails 4.0 and the attr_accessible isn't used by Rails 4.0.

Is it safe to assume that the steps as mentioned in the video aren't needed with Rails 4.0?

Everything works fine without the code in the video but as Jason mentions there might be security problems with users making their roles admin.

2 Answers

Roberto Alicata
PLUS
Roberto Alicata
Courses Plus Student 39,959 Points

you can try to add this in the application_controller.rb

  before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :last_name, :profile_name, :email, :password, :password_confirmation) }
  end  
Lee Hughes
Lee Hughes
8,380 Points

Never mind - continuing with rails 4.0 installed I ran into a lot of problems later in the course. I had to delete my progress and start again with older rails version. :(