I want to change what happenes in devise when a user logs in.. When I look at the source code the word resource is everywhere, but I can't understand what it is a stand in for. Does it only pertain to devise and warden?
def after_sign_in_path_for(resource)
stored_location_for(resource) ||
if resource.is_a?(User) && resource.can_publish?
publisher_url
else
super
end
end
As Devise support OmniAuth integration by default. In order to do so it creates two extra column provider and uid where provider consist oAuth provider i.e facebook, google, linkedin etc. and uid will consist unique id of the user who logged in using oAuth.
Devise is the cornerstone gem for Ruby on Rails authentication. With Devise, creating a User that can log in and out of your application is so simple because Devise takes care of all the controllers necessary for user creation ( users_controller ) and for user sessions ( users_sessions_controller ).
Now that you have set everything up you can create your first user. Devise creates all the code and routes required to create accounts, log in, log out, etc. Make sure your rails server is running, open http://localhost:3000/users/sign_up and create your user account.
Resource is an abstraction name of instance of a user. It can be configured in devise settings to work with Admin model or any other.
By default it's the first devise role declared in your routes
devise :users # resource is instance of User class
devise :admins # resource is instance of Admin class
Alex's answer says it succintly, but it may not be clear to everyone, given the comment above:
The authors of devise realise that those who use the gem will want it customised differently. Some people will want to call their users: Users, others will want to call them: Swimmers, or Golfers, or Presidents, as the case may be. "Resource" is basically a substitute for the name of the users that app developers will utilize in the future. Devise doesn't care what users are actually called: no matter what it is called, to devise, your users will be known as simply "resource". If it had been any other way, then the authors of the gem would have to force app developers to call their users: Administrator, or Admin - which is very restrictive and developers will not like that.
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