cecile
cecile

Reputation: 293

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.

Upvotes: 6

Views: 1693

Answers (2)

Mika
Mika

Reputation: 1479

Posting Jeff Paquette's comment as an answer.

Update the config/initializers/active_admin.rb with:

config.logout_link_method = :delete

Upvotes: 3

RohitPorwal
RohitPorwal

Reputation: 1065

Please make changes in your routes.rb :-

devise_scope :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks"} do
  get "/users/sign_out", :to => "devise/sessions#destroy"
end

I am also getting same problem, only this can resolve me after 1hr time wasting.

Thanks.

Upvotes: 0

Related Questions