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

Generating the Devise Views : Empty :first_name, :last_name and :profile_name

I just finish "Generating the Devise Views" and after registration, when I look my database. The column first_name, last_name and profile_name are both empty (NULL).

I do everything like in the course and no error message cames, so what can I do to fix it ?

4 Answers

Do you have this in your application controller? If not, paste it in, save it, and try it again. There are differences in Rails 3 (which the vide are using) and Rails 4 which some of us have been using. Too bad Treehouse hasn't as much as made a guide/blog post about it. Or if they have, I can't find it and it should be in the guide somewhere.

code:

class ApplicationController < ActionController::Base before_filter :configure_permitted_parameters, if: :devise_controller? # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception

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

end

Which part do I put in? I seem to have the same problem as Jesse.

You could try populating db info in the rails console?

In console, I have :

Started POST "/users" for 127.0.0.1 at 2013-09-05 15:53:25 +0200
Processing by Devise::RegistrationsController#create as HTML
Parameters: {"utf8"=>"?", "authenticity_token"=>"iGajM+dKXkUVpKGUxsgZTkBnea4VyiuMpcOQELrxgak=", "user"=>{"first_name"=>"MyName", "last_name"=>"MyLastName", "profile_name"=>"MyProfileName", "email"=>"MyEmail", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
Unpermitted parameters: first_name, last_name, profile_name

Thank you very much, It's working pretty well ! Thanks for answering so fast :)