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

undefined method 'full name' for nil:NilClass

i'm getting this error when i go to /statuses.

I added a 'before_filter :authenticate_user!' on my StatusesController

what happens is that i need to login before i can view my status.

how do i make it work so that i can view different statuses from other users even when logged out? if i remove the 'before_filter' i get 'undefined method `full_name' for nil:NilClass' error

1 Answer

Hey Joanthan it's likely you have created a status that is not associated with a user. So when you try to call

.full_name

on one of your statuses it errors out.

If you don't mind deleting your local data try this in your terminal.

rails c 

This will allow you to interact with your application from the command line.

Status.all

This will give you a listing of all the statuses you have in your local db, then do-

Status.destroy_all

This will delete all the Statuses in your local db, now you should be able to access /statuses in your browser but there will not be any because you just deleted them from the command line. So try creating a new status and be sure to associate it with a User otherwise you will get the same error.

Alternatively, just as a check that this is the problem, you could (temporarily) remove the line

<%=link_to status.user.full_name, profile_path(status.user) %>

from your app/views/status/index.html.erb file and you should be able to access the page in your browser. If this is in fact the cause of the error. It might be good to do this first before deleting test user data.