1

I'm using user_signed_in? to check if the user is logged in to display the logout link if not logged in it will display the login link, but for some reason it's only show the login link either if the user is signed in or not. And when i click on the login link it will say the user signed in already. in this case it should display the log out link but it does not.

<%if user_signed_in?%>
  <%= link_to "Logout", destroy_user_session_path, method: :delete%>
<%else%>
  <%= link_to "Login", new_user_session_path %>
<%end%>
  • what about <% if current_user.present? %> ? – Ahmad Al-kheat Mar 11 '15 at 02:14
  • 1
    if the user logged in already It display the login link even and won't display the logout link. – Sammykhaleel Mar 11 '15 at 02:59
  • Have you tried logging/ displaying `current_user` and `user_signed_in?` to pinpoint where the problem is? Or logged from your controller to make sure that the user is _actually_ signed in? Because chances are you've messed up some part of the login. – Will Richardson Mar 11 '15 at 03:44
  • When i click on the login link it will say the user signed in already. in this case it should display the log out link but it does not. – Sammykhaleel Mar 11 '15 at 04:07

0 Answers0