【发布时间】:2011-12-14 02:44:44
【问题描述】:
在设计中,我如何访问用户的身份验证令牌。当 ajax 调用启动用户会话时,我需要能够从用户那里获取身份验证令牌。我尝试做一些事情,比如在我的模型中添加 :token_authenticable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
还将名称的属性(例如 :authentication_token 和 :authenticity_token)添加到 attr_accessible。但是每次我尝试使用 user.auth 从用户中调用 authentication_token 或这个authentity_token ......我都会遇到这样的错误
NoMethodError: undefined method `authentication_token' for #<User:0x000001016b1140>
抱歉,我需要让这个令牌与我的 ajax 调用一起发送,(我从事的最后一个项目有一个令人难以置信的 BOOTLEG 解决方案,其中设计几乎从应用程序中被撕掉,我只需要这个该死的令牌)
【问题讨论】:
-
我遇到了类似的问题,如果你找到了解决方案,请告诉我,没有好的阅读材料可供选择
-
token_authenticable 已贬值,如下所示:stackoverflow.com/questions/18931952/…
标签: ruby-on-rails ruby devise gem