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
Bede Fahey
621 PointsTesting The Statuses Controller: Undefined Method for "Full Name"
Hi everyone,
I'm currently on the "Testing the Statuses Controller" video, and when I run the test, I get an error:
Undefined method 'Full Name' for nil:NilClass
This is for the
test_should_get_index test
The error goes away when I delete this line of code from index.html.erb
9: <strong><%= status.user.full_name %></strong>
I've tried migrating the database, and reviewing the videos where full_name was created.
Any help much appreciated.
10 Answers
Jason Seifer
Treehouse Guest TeacherHey Michael Hopkins that means you have no statuses. Try creating some!
Andy Brown
6,310 PointsI am also getting this error. I just cloned the project at the beginning of Stage 7 from github and am still getting the error. Any help is appreciated!
Jason Seifer
Treehouse Guest TeacherIf you don't mind having any statuses be attributed to the first user in the system, try doing the following:
bundle exec rails console
Status.all.each {|status| status.update_attribute(:user_id, User.first.id)}
This will assign any statuses without a user_id attribute to the first user and should ideally fix the error.
This is only one way to do it, you could also delete and recreate all statuses.
Jacob Christiansen
3,193 Pointsthe way to fix it is to open the rails console
type:
rails console
Status.delete_all
exit
rails s
I think the problem is you have previous statuses with no first or last _name
jadaml
11,593 PointsThanks Jacob! that did it for me.
Jacob Christiansen
3,193 PointsGlad I could help Jadam
Michael Hopkins
Courses Plus Student 2,049 PointsUnfortunately neither of those fixes did it for me. I am still getting this error. I have attempted both Jacobs and Jason's solution. Thoughts?
Jacob Christiansen
3,193 PointsHave you tried restarting the server? What does Status.all in the console return? (it shouldn't return anything after you've issued Status.delete_all)
Michael Hopkins
Courses Plus Student 2,049 PointsAfter doing several things to the development database the error seems to have gone away. Several things being everything from using a different computer, deleting the /db/development.sqlite3 file, and remigrating the database. However now I am getting a similar error on the 'gravatar_url' method. I have created a new thread found here
Michael Hopkins
Courses Plus Student 2,049 Pointsedit: I am still getting this error. upon running Status.all the following is returned.
=> []
Claudio Silva
2,960 PointsWhen you create a new user on your application, you will enter first name, last name and profile name in the register form, plus email and password. So, remember that when you call http://localhost:3000/xxxxxx The xxxxxx must be the PROFILE NAME entered when you registered the user, and not the first and last name together.