Does Devise create session table? If it does, how to access the session variables created by Devise?

3,413 views
Skip to first unread message

emcla...@gmail.com

unread,
Dec 21, 2012, 2:16:13 AM12/21/12
to plataforma...@googlegroups.com
If using Devise, do we still need to create session table in rails app (Devise is a rails engine as we understand)? If Devise is going to create session table, then how do we access the session? For example, we can use session[:user_id] to access user_id in rails app. Is it user_session[:user_id] with Devise?

Carlos Antonio da Silva

unread,
Dec 21, 2012, 6:45:28 AM12/21/12
to Devise
Devise doesn't do anything specific regarding the way you configure your session storage. If you configure it to be the Active Record one, you'll have to create the table yourself and configure whatever is necessary to have it working by yourself.


On Fri, Dec 21, 2012 at 5:16 AM, <emcla...@gmail.com> wrote:
If using Devise, do we still need to create session table in rails app (Devise is a rails engine as we understand)? If Devise is going to create session table, then how do we access the session? For example, we can use session[:user_id] to access user_id in rails app. Is it user_session[:user_id] with Devise?

--
 
 
 



--
At.
Carlos Antonio

emc lab

unread,
Dec 21, 2012, 11:27:22 AM12/21/12
to plataforma...@googlegroups.com
Carlos,

Did you mean Devise does not create session table and we (developer) need to create it on our own in our rails app?

Thanks.
-emclab

--
 
 
 

Carlos Antonio da Silva

unread,
Dec 21, 2012, 1:07:14 PM12/21/12
to Devise
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.

emc lab

unread,
Dec 21, 2012, 2:00:59 PM12/21/12
to plataforma...@googlegroups.com
Carlos,

Thanks for the info. We are using a rails 3.2.8 mountable engine authentify for some user verification job. Can we leave the session creation to engine authentify? Or it is better for rail app (main app) to handle the session creation.

Thanks.
-Jun

--
 
 
 

Carlos Antonio da Silva

unread,
Dec 21, 2012, 3:23:00 PM12/21/12
to Devise
Usually migrations from engines have to be copied to the application, even though there are ways to workaround that. If you're using your own engine and want to leave most of the code on it, you can provide a migration in the engine itself and use the rake task that the rails engines already provide to copy it over to you.

In any case, I'd just do that if the engine itself has a specific session storage that needs its own table structure, otherwise, if you're using AR SessionStore, I'd just keep it simple and run the generator that creates the migration in the app, and document that in the engine.

On Fri, Dec 21, 2012 at 5:00 PM, emc lab <emcla...@gmail.com> wrote:
session



--
At.
Carlos Antonio

emc lab

unread,
Dec 21, 2012, 11:55:19 PM12/21/12
to plataforma...@googlegroups.com
Thanks for the insight. Happy holidays!

--
 
 
 

Reply all
Reply to author
Forward
0 new messages