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

Lisa Rossiter
Lisa Rossiter
3,630 Points

NoMethodError: undefined method `full_name' for nil:NilClass

I only get this error in my test database and cannot figure it out please help. I am getting a few errors simular to this and cannot figure it out. I am so close to saying f** testing the actual app works. :)

2 Answers

Ethan Lowry
PLUS
Ethan Lowry
Courses Plus Student 7,323 Points

If it only happens with your test database then either:

  • The structure of your test database is not up to date with whatever migrations have been applied to your dev DB, in which case you need to run rake db:test:prepare. Or,

  • You have made some error in your test itself - in this case you're probably best off posting your test code here for people to see. (Have you definitely correctly assigned whatever instance you're calling 'full_name' on?)

Remember, it's never worth saying 'f*** it' with tests, as tempting as it can be ;)

Thanks and good luck.

Lisa Rossiter
Lisa Rossiter
3,630 Points

You was correct Ethan,

It was me being an idiot in the end I added a few bits that required current_user from devise and I had not updated my tests to login a user. I appreciate your detailed help thank you.