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

Adding profilename & last/first_names to devise sign_up page

I'm using ROR 4, My problem is when I go through the steps shown on the video to fetch profile and first and last names off users as well as email on the sign_up page, nothing would be passed into my database and they are stored as 'nil'(default devise fields such as email and password get through though). I've had a glance at Devise documentation but couldn't find anything about adding extra fields either. Any help would be much appreciated!

1 Answer

This is due to the introduction of the Strong Parameters in Rails4

Add this code in app/controllers/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, :avatar) }
  end