本文介绍了#User 的未定义局部变量或方法“confirmed_at"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Rails 3.可能存在重复的 这里.但它没有解决我的问题,也没有解决任何其他解决方案.

I am using Rails 3. There is a possible duplicate here. But it did not solve my problem, neither did any other solution.

我的迁移如下

class AddConfirmableToDevise < ActiveRecord::Migration
  def change
    change_table(:users) do |t|
      t.confirmable
    end
    add_index  :users, :confirmation_token, :unique => true
  end
end

我确实在 User 模型中添加了 devise :confirmable.

I do have devise :confirmable added in User model.

我的 rake db:migrate 没有输出.我的注册页面出现错误:

My rake db:migrate gives no output. and my sign up page gives the error:

undefined local variable or method 'confirmed_at' for #User

有人知道吗?

推荐答案

好的.我解决了.迁移已过时.使用相同的代码但不同的名称生成新的迁移.

Ok. I solved it. The migration is outdated. Generate new migration with same code but another name.

1.运行命令:

rails g migration add_confirmable_to_devise_v1

2.在迁移文件中:

class AddConfirmableToDeviseV1 < ActiveRecord::Migration
  def change
    change_table(:users) do |t|
      t.confirmable
    end
    add_index  :users, :confirmation_token, :unique => true
  end
end

3.然后

rake db:migrate

这篇关于#User 的未定义局部变量或方法“confirmed_at"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 06:27