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 filter in your controller?
I had encountered exactly the same issue and solved it by doing
$bundle exec rails g devise user
again. My problem wasdevise_for users
was somehow missing in the routing file.This could be a possible explanation.
You might have a pre-existing
current_user
method which stops Devise'scurrent_user
called withinuser_signed_in?
from returning expected values.Make sure that you are using the right model. For example if your model is member then you should use
member_sign_in
instead ofuser_sign_in
.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.
If login is working properly, it could be because of some kind of caching going on?