【问题标题】:Authlogic: getting an undefined method `password' for #<User:Authlogic:获取#<User: 的未定义方法“密码”
【发布时间】:2009-09-05 07:32:08
【问题描述】:

即使我在模型中添加了“acts_as_authentic”,我似乎也无法让 Authlogic 中的用户模型理解“密码”方法。 Authlogic 灯塔上也报告了这个问题,但没有人描述他们是如何解决的:

http://binarylogic.lighthouseapp.com/projects/18752/tickets/128-undefined-method-password-on-rails-231#ticket-128-9

用户表包含所有必填字段,控制器和其他所有内容都绝对遵循教程。

有人知道可能是什么问题吗?

(哦,我正在运行 Rails 2.3.3,Authlogic 2.1.1)

【问题讨论】:

  • 由于 authlogic 为我工作 (tm),您必须提供有关您的错误的更多信息。堆栈跟踪会很好:)

标签: ruby-on-rails authentication passwords authorization authlogic


【解决方案1】:

我将“crypted_pa​​ssword”拼错为“crypted_pa​​sswond”。啊!

对于所有其他人,请确保您的数据库中有所有必需的列。

【讨论】:

    【解决方案2】:

    确保您的用户模型使用acts_as_authentic

    #app/models/user.rb
    class User < ActiveRecord::Base
      acts_as_authentic
    end
    

    我进行了各种故障排除,并在解决其他问题时以某种方式将其删除。

    【讨论】:

    • 谢谢!我是 Rails 新手,你的回答让我避免了很多挫败感!
    【解决方案3】:

    安装 authlogic 后,您是否重新启动了应用程序?有了Passenger,touch tmp/restart.txt 就可以了。

    【讨论】:

      【解决方案4】:

      我遇到了同样的问题,最后意识到我的用户路线是错误的。我打错字了

      map.resources user
      

      当我修复并更改为这个时,authlogic 识别出密码字段

      map.resources.users
      

      【讨论】:

        猜你喜欢
        • 2011-07-02
        • 2012-05-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-09
        • 2017-01-22
        • 1970-01-01
        相关资源
        最近更新 更多