I have been following the Railscast #270 found Rails Cast #270 about implementing Authentication in Rails 3.1. What I would like to do is have the ability in my templates to have different links displayed if a user is logged in. It should look something like this.
If user logged in
Display link to Profile
Display logout
If user logged out
Display link to register
Display link to login
I think I can figure out the link to various places from theRailsTutorial, but I'm stuck on how to tell if a user is signed in or not.
Using the rails tutorial I found this snippet
<% if signed_in? %>
<li><%= link_to "Profile", current_user %> sfsdfsdf</li>
<% end %>
Which doesn't work when I put the following in my sessions helper:
def signed_in?
!@current_user.nil?
end
How would you make this work?