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 Problems [Rails 4.1.1]

I've been doing some research before requesting help from the forums, but I cannot quite find the solution to my problem. I currently have problems implementing the first name and last name in the index page as well as the 'show' page. Adding code in the following pages:

[index.html.erb]

<strong><%= status.user.first_name %></strong>

[show.html.erb]

<%= @status.user.first_name %>

seems to be, repeatedly, causing this error to appear:

undefined method `first_name' for nil:NilClass

I decided to do some research on the forums afterwords and found this piece of information, but it did not help:

[statuses_controller.rb]

    def status_params
      params.require(:status).permit(:name, :content, :user_id)
    end

I also looked at a Devise controller mentioned by Jason, but I do not know what to do with the piece of code provided. Do I simply make a Devise controller and put it in the "Controller" directory or is there something else to it?

Either way, I am stuck with adding the users first name let alone their last. Can anyone guide me through this problem?

David Curtis
David Curtis
11,301 Points

what happens when you make it just @user.first_name?

David Curtis :

undefined method `first_name' for nil:NilClass

1 Answer

You know what. I'm going to follow each track with it's exact version. Close this thread.