Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Devise, can't log out

In a Rails app, I use devise to manage my users and my link to destroy a session no longer work. It was working, and now I have add active admin, It doesn't.

My link is

<%= link_to "Déconnexion",  destroy_user_session_path, :method => :delete, :class => 'button'  %>

My routes.rb

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks"}

My rake routes

destroy_user_session DELETE /users/sign_out(.:format)

And it try to open the view /users/sign_out, so I have :

ActiveRecord::RecordNotFound in UsersController#show

Couldn't find User with id=sign_out

Does Active_admin and Devise crash together? It will be weird 'cause active use devise, no?

Edit:

For the next person who will have this issue, I solved it by adding the next line to /config/initializers/devise.rb.

config.sign_out_via = :get

Not exactly the finest way, but it does the job.

like image 836
cecile Avatar asked Nov 04 '12 18:11

cecile


1 Answers

Posting Jeff Paquette's comment as an answer.

Update the config/initializers/active_admin.rb with:

config.logout_link_method = :delete
like image 135
Mika Avatar answered Sep 28 '22 00:09

Mika