Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exaclty are scopes in devise?

Sorry for stupid question, but what exactly are scopes in devise? Problem I run into is that I want to add sign_out method to my controller, and I can't do it because config.sign_out_all_scopes is set to true by default, so changing it to false would help, but I don't understand what this config actually does. It looks like being true it will sign out all :admins or all :users by signing out one, but it doesn't make sense to me. Is "scope" actually a user? What exactly will change if I toggle this option? Thanks a lot in advance.

like image 752
Olga Scott Avatar asked Oct 04 '22 09:10

Olga Scott


1 Answers

Devise allows you to separate your users into different "scopes" such as "admin" and "member", the effect of this is that you get a set of routes, controllers and views for each scope.

A user can belong to multiple scopes and sign in to any/all of them at any time - so when the option sign_out_all_scopes is true, signing out as any scope will sign out all of that users currently signed in scopes.

Regarding your specific question - why are you defining your own sign out method? Devise provides one for you. If you want to modify the sign out method make sure you follow the instructions for properly extending the devise controllers.

like image 78
Matt Avatar answered Oct 07 '22 18:10

Matt