Welcome to the Treehouse Community
Looking to learn something new?
Problem with register users
Hi, I try to learn something about Rails and follow the Treebook tutorial. I've come to that stage when we install devise. And devise is installed with no problems. and I can register a new user without a problem. But I always get a error message "undefined method `full_name' for nil:NilClass"
app/views/statuses/index.html.erb:9:in `block in _app_views_statuses_index_html_erb___3166094988121289217_70208237682380' app/views/statuses/index.html.erb:5:in `_app_views_statuses_index_html_erb___3166094988121289217_70208237682380'
And I've try to solve this problem by my self, and I had try to delete all statuses & Users multiple times, without success.
When I do Rails c ->
U = User.First I get following code.
irb(main):001:0> U = User.first User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 => #<User id: 4, first_name: nil, last_name: nil, profile_name: nil, email: "firstname.lastname@example.org", encrypted_password: "$2a$10$E3O/AblpU7jYgPFU.qEeWuo7uSPABnaCQoKL2UgOWtvJ...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2013-09-14 11:45:18", last_sign_in_at: "2013-09-14 11:45:18", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", created_at: "2013-09-14 11:45:18", updated_at: "2013-09-14 11:45:18">
It seems like devise don't register full name, last name & profile name ?! Can this be the problem and how do I fix it?
Alan Johnson7,625 Points
So the error "undefined method X for nil:NilClass" pretty much always guarantees that you're calling a method on nil that you're meaning to be calling on an object. In this case you're calling
full_name on nil. Since it's happening in your view, that probably means that you're not logged in, but I'll need to see your view code to know for sure.