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

can not update extra fields in database

I am using gem 'devise' and edit 3 more fields: first_name, last_name and profile_name but after I fill in registration form, I get an error: undefined method `+' for nil:NilClass

1 Answer

ok, I can fix this issue after searching on the internet and the reason is concern with strong_parameters in gem devise. Here is my error in development log file: Unpermitted parameters: first_name, last_name, profile_name

So I resolve it follow this way: Add these code below in controllers/application_controller.rb

before_filter :update_sanitized_params, if: :devise_controller?

def update_sanitized_params devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:first_name, :last_name, :profile_name, :email, :password, :password_confirmation)} end