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 during Navigation links tutorial

I no longer need this answered, I figured it out, my session expired in the app so there was no current user defined.

Following the instructions in the Navigation Links tutorial I have added the following code as instructed in the tutorial to my application.html.erb file:

<div class="navbar fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <a href="#" class="brand">Treebook</a>
            <ul class="nav">
                <li><%= link_to "All statuses", statuses_path %></li>
            </ul>
            <ul class="nav pull-right">
            <li><%= link_to current_user.full_name, "#" %></li>
            </ul>
        </div>
    </div>
    </div>

After saving and refreshing the page, I get a undefined method 'full_name' error, user.full_name works everywhere else in the application, but I can't seem to figure out why it is not working for this page. I hate to move on the tutorial without knowing what I am doing wrong. Anyone have any insight?

1 Answer

Wilson Usman
Wilson Usman
35,206 Points

Daniel, first I would launch your rails console and verify that all users have a first name and last name defined. If they don't, you can delete the user, or define the first and last names.

This is why I was getting the same error. Let me know if this helps.