I have implemented Authlogic to my app, but I am confused about the sense of the table sessions
.
我已经对我的应用程序实现了Authlogic,但是我对表会话的意义感到困惑。
I have UsersController
, UserSessionsController
, for both controllers models. In the database - the table users
and the table sessions
.
我有UsersController, UserSessionsController,用于两个控制器模型。在数据库中——表用户和表会话。
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
).
表会话一直是空的。我尝试将这个表重命名为user_sessions,但同样的情况——仍然是空的表(如果我登录到我的应用程序,没有向表会话/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.
但是我的应用运行得很好,登录和注销都很好,同样的注册,如果我测试logged_in_timeout -这也很好。
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
谢谢
2 个解决方案
#1
3
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.
实际上,会话并不需要一个数据库表,除非您想要将它们持久化,以便处理故障转移和应用程序重新启动等问题。UserSession模型可以声明如下,不需要扩展AR。
class UserSession < Authlogic::Session::Base
...
end
#2
0
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.
Steakchaser关于不需要在数据库中存储会话是正确的。但是,为了更直接地回答您的问题,它不能工作的原因是配置。在config /初始化/ session_store session_store。rb默认为:cookie_store;如果将其设置为:active_record_store,会话表将按预期填充。
More instructions on how to implement ActiveRecord for sessions can be found here.
关于如何为会话实现ActiveRecord的更多说明可以在这里找到。
#1
3
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.
实际上,会话并不需要一个数据库表,除非您想要将它们持久化,以便处理故障转移和应用程序重新启动等问题。UserSession模型可以声明如下,不需要扩展AR。
class UserSession < Authlogic::Session::Base
...
end
#2
0
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.
Steakchaser关于不需要在数据库中存储会话是正确的。但是,为了更直接地回答您的问题,它不能工作的原因是配置。在config /初始化/ session_store session_store。rb默认为:cookie_store;如果将其设置为:active_record_store,会话表将按预期填充。
More instructions on how to implement ActiveRecord for sessions can be found here.
关于如何为会话实现ActiveRecord的更多说明可以在这里找到。