Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.