Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails devise Sessions Controller

In devise, many of the pages that teach how to accomplish certain things require editing a sessions controller. I set up devise using this https://github.com/fortuity/rails3-subdomain-devise/wiki/Tutorial-(Walkthrough) It didn't go over making a sessions controller. How do I make one. (If it's really easy i'm sorry, just give me the few simple steps)

like image 471
Kevin Avatar asked Oct 21 '11 20:10

Kevin


People also ask

How does devise session work?

Devise uses the session storage that Rails is configured to. So it depends on which session storage you will use in your app, not on Devise. If you want to store the session data in the database, then yes, you need to tell Rails about that and run the Rails generator that creates the database table for you.

Does devise work with Rails 7?

Our out-of-the box Devise setup is now working with Rails 7. Once again, if you'd like to refer to any of the code for this setup, or use the template wholesale for a new app, the code is available on GitHub, and you may also use it as a template repo to kick off your own Rails 7 devise projects.


1 Answers

Create your Sessions Controller with rails g controller MySessions. Then inside of your controller change it from inheriting from ApplicationController to the Devise Controller like so:

class MySessionsController < Devise::SessionsController

#your session logic here

end

Any of the logic within that controller that you want to override you can override by calling that method and inserting your own logic. For the list of what's in that controller, you can view the code on their Github page. If you do not wish to override their methods you can either leave them out, or just call super.

def new
  super
end
like image 105
janders223 Avatar answered Oct 20 '22 09:10

janders223