I have a button on my web page that redirects my from the user index with params back to the user index. My problem is that when I navigate back to the users_path through a button I get a message form devise saying "You are already signed in." This happens even though I was not trying to sign in and was only navigating back to the same page but removing the params.
The button in question looks like,
<%= button_to "All Users", users_path, class: "button expand" %>
I searched all my files for instances of "You are already signed in." and the only refrence is in the devise.en.yml where it says already_authenticated: "You are already signed in."
You can also edit the message in config/locales/devise.en.yml:
failure:
already_authenticated: ''
Then wherever your flash messages are displayed in your view:
- if flash[:alert].present?
...
The DeviseController
is generating this message from method require_no_authentication
. This method is used as a before_filter
on pages like the one for signing in or other similar actions that are useless for signed in users. It redirect to the after_sign_in_path
for the resource and sets that flash
message. You'll have to either overwrite the require_no_authentication
method or generate a new controller that does not use the before_filter
.
This was happening because I was using a button_to rather than a link_to. A button_to attaches a POST request as opposed to a link_to which attaches a GET request. With the attached post request rails was looking to a different action in the controller than the one intended.
If creating a refresh method on an index or show page always use a link_to helper or a helper that attaches a GET request.
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