omniauth 的 session[:user_id] 中的 :user_id 是什么?
我正在尝试将omniauth 合并到我的rails 应用程序中。但我想知道,用于 session[:user_id] 的 :user_id 是什么?我看到它在教程中一直使用,但我不确定它是如何创建或如何工作的。
谢谢!
I'm trying to incorporate omniauth in my rails application. I was wondering though, what is the :user_id that is used for session[:user_id]? I see it used all the time in tutorials but I'm not sure how it's created or how it works.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 OmniAuth 和任何授权 gem 中,您将需要至少两个模型。
他们通过外键相互引用,该外键与引用模型的会话相关联。
通过这种方式,应用程序可以监视会话数据、当前登录,甚至使用会话数据来移动临时信息。例如,在商店中,将使用用户会话,以便在产品被挑选和实际购买之间的时间空间内将产品分配给用户。
祝你好运!
In OmniAuth and any Authorization gem, you will require at least two models.
They refer to each other through a foreign key which is tied to the Session referring to the model.
In this way, an application can monitor session data, current logins, and even use session data to move temporal information. For example in a store, a user session would be used in order to allocate a product to a user in the timespace between it being picked out and actually purchased.
Good luck!