Question

I just set up devise for my Rails application. It was with the "user" model.

When I look at the routes created, I can see :

destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy

Though, no script intended to destroy the session has been created when I installed Devise.

I'm a little bit lost there...do I have to create this script ? If yes, where do I have to put it ? In the views ? But is it really a view ?

And last but not least, what do I have to put in it ?

Thank you a lot.

Was it helpful?

Solution

No you do not have to write a script for destroy_user_session. This is handled by the destroy action of the devise's SessionsController which is already available since you've installed devise gem. unless you want to change the default behavior of destroy action, all you need is a link to the action on your view to destroy the session like this:

<%= link_to 'Sign out', destroy_user_session_path, :method => :delete %> and devise will destroy the current session

OTHER TIPS

Devise is an engine, so you have proper controller (Devise::SessionsController) that handle this request in devise gem code. That means this route should work out of the box.

Devise github page (with tutorial) here: https://github.com/plataformatec/devise

More about Rails engines here: http://guides.rubyonrails.org/engines.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top