omn​​iauth 的 session[:user_id] 中的 :user_id 是什么?

发布于 2024-12-19 13:31:51 字数 124 浏览 2 评论 0原文

我正在尝试将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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心的位置 2024-12-26 13:31:51

在 OmniAuth 和任何授权 gem 中,您将需要至少两个模型。

  1. 用户模型(当他们创建用户时)
  2. 用户会话(当他们登录时,该模型对象由他们的用户创建)

他们通过外键相互引用,该外键与引用模型的会话相关联。

通过这种方式,应用程序可以监视会话数据、当前登录,甚至使用会话数据来移动临时信息。例如,在商店中,将使用用户会话,以便在产品被挑选和实际购买之间的时间空间内将产品分配给用户。

祝你好运!

In OmniAuth and any Authorization gem, you will require at least two models.

  1. User Model ( When they create a User )
  2. User Session ( When they are logged in this model object is created by their User )

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文