加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 未定义的局部变量或#User的“confirmation_at

发布时间:2020-12-16 20:23:29 所属栏目:百科 来源:网络整理
导读:我正在使用Rails 3.有可能是重复的 here.但它没有解决我的问题,也没有任何其他的解决方案. 我的迁移如下 class AddConfirmableToDevise ActiveRecord::Migration def change change_table(:users) do |t| t.confirmable end add_index :users,:confirmation_
我正在使用Rails 3.有可能是重复的 here.但它没有解决我的问题,也没有任何其他的解决方案.

我的迁移如下

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

我有设计:确认添加在用户模型.

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

undefined local variable or method 'confirmed_at' for #User

有人有线索吗?

解决方法

好.我解决了迁移过时了.使用相同的代码生成新的迁移,但另一个名称.

运行命令:

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,:unique => true 
  end
end

3.Then

rake db:migrate

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读