I have this in my view:
<% if user_signed_in? %>
<%= current_user.email %>
<% else %>
<%= link_to "Sign in", new_user_session_path %><br />
<%= link_to "Opret", new_user_session_path %><br />
<% end %>
But when have signed in as a user: I still get the links in view:
<%= link_to "Sign in", new_user_session_path %><br />
<%= link_to "Opret", new_user_session_path %><br />
Why is the helper not working?
Did you use devise's before action in your controller?
before_action :authenticate_user!
Not sure what is behind the user_signed_in? method, either your login is not working correctly or your method is broken.
Maybe try this, if that doesn't work, I would take a look at whats going wrong with the actual login.
<%unless current_user.blank? -%>
signed in
<%else -%>
not signed in
<%end-%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With