Im trying to display the current users name in a button in my nav if they are signed in.. I dont use the Home controller for anything, why is it asking for name to be defined in there? Any page involving a different controller give an error when trying to render user.name in the nav..
NoMethodError in Home#index
Showing /Users/nelsonkeating/Desktop/ReminDeal/app/views/layouts/_navigation.html.erb where line #10 raised:
undefined method `name' for nil:NilClass
Extracted source (around line #10):
7: <% if user_signed_in? %>
8: <div class="logout1">
9: <div class="btn-group">
10: <button class="btn"><Action> <%= @user.name %> </button>
11: <button class="btn dropdown-toggle" data-toggle="dropdown">
12: <span class="caret"></span>
13: </button>
<ul class="dropdown-menu">
<li><%= link_to 'Logout', destroy_user_session_path, :method=>'delete' %></li>
<li><%= link_to 'My Account', edit_user_path(current_user.id) %></li>
<li><%= link_to "Help", help_path %></li>
</ul>
</div>
</div>
</li>
Have you declared the @user in the controller?
Try changing the line 10 to: