Session handling and signing in/out
I'm developing Rails application and I have to use authentication. I installed devise gem and trying to get used to it. Anyway - I have 2 problems, which may be connected (don't know it)
When signing in, how to sign out user, that is already signed in as the same user? I mean - From machine M1 someone signed in, next from machine M2, the other user is signing in. I want to sign out user from M1
How to store data information in session? I will have 3 forms, some dependent to 开发者_如何学JAVAother, and only after last one I need to create entry in database. I wanted to store other information in session. How to do it, or is it bad idea?
1) this routes ends the session with devise
destroy_user_session GET /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
just add a link pointing to "/users/sign_out" and it will sign out the user. I dont follow the part about user in M1 and M2 but you can sign out all users at once with sign_out_all_scopes
2) session[:anything] = 'value_you_want' will store information in the session, remember that by default session store is set in a coockie so you only have 40k to store data.
If you want to make a wizard like form i recommend going to www.railscasts.com and search for "wizard", there is a screencast there of how to achieve what you want.
精彩评论