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

Creating Relationships Error undefined method `full_name' for nil:NilClass

So I've been stuck on this for awhile and have read some of the other discussions on this, but I still haven't been able to figure it out myself.

I followed everything exactly as in the tutorial, yet I continue to get this error:

NoMethodError in Statuses#show

Showing /Users/jeromecjohnson/Desktop/treehouse- rails/newshare/app/views/statuses/show.html.erb where line #5 raised:

undefined method `full_name' for nil:NilClass Extracted source (around line #5):

2: 3: <p> 4: <b>Name:</b> 5: <%= @status.user.full_name %> 6: <p> 7: <b>Content:</b> 8: <%= @status.content %> Rails.root: /Users/jeromecjohnson/Desktop/treehouse-rails/newshare

Application Trace | Framework Trace | Full Trace app/views/statuses/show.html.erb:5:in _app_views_statuses_show_html_erb__4325490691339574105_2181330260' app/controllers/statuses_controller.rb:18:inshow'

I'm thinking its because my "first_name" and "last_name" variables aren't set. How can I set these vars? Also, if that isn't the problem, what is it?

1 Answer

You must first create this method before using it. Did you write the method "full_name" in a helper, or a library?

I defined the method in the user.rb model, I'll try it as a helper