質問

I have implemented Authlogic to my app, but I am confused about the sense of the table sessions.

I have UsersController, UserSessionsController, for both controllers models. In the database - the table users and the table sessions.

The table sessions is all the time empty. I tried to rename this table to user_sessions, but the same case - still empty table (if I log in to my app, there is not added a row to the table session/user_session).

But my app is working well, the login and logout is working well, the same registration, also if I test logged_in_timeout - this is working well.

So, what am I missing about the sessions? This make me a little bit confused, what is the point of this table, if in my case are no rows saved there and everything seems to be working fine.

Thanks

役に立ちましたか?

解決

You don't actually need a database table for the sessions unless you want to persist them for dealing with things like failover and application restarts. The UserSession model can be declared as follows, and does not need to extend AR.

class UserSession < Authlogic::Session::Base
  ...
end

他のヒント

Steakchaser is correct about not needing to store sessions in the database. However, to answer your question more directly, the reason it wasn't working is the config.session_store in config/initializers/session_store.rb defaults to :cookie_store; had this been set to :active_record_store, your session table would have been populated as expected.

More instructions on how to implement ActiveRecord for sessions can be found here.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top