#<User:0x007f28a2101568> 的未定义局部变量或方法 `locked_at' 您是说吗? lock_access

undefined local variable or method `locked_at' for #<User:0x007f28a2101568> Did you mean? lock_access

所以我在 rails 上的 ruby 中创建了一个项目,用于使用 devise 和 facebook 进行身份验证。通过设计简单注册登录时,我收到以下错误:

undefined local variable or method `locked_at' for # Did you mean? lock_access!

我认为没有为用户添加 locked_at 列 table

生成用于在用户中添加列的迁移 table

  def change
    add_column :users, :locked_at, :datetime
  end

对于那些像我一样从 Google 来到这里的人,您可能还需要注意 Devise 入门自述文件中的这一行 - https://github.com/plataformatec/devise#getting-started

Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration.

仔细检查您的 Devise 用户迁移文件 (db/migrate/TIMESTAMP_devise_create_users.rb) 并取消注释任何必要的部分。在这种情况下,与 Lockable 模块相关的部分。