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

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.