微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我正在使用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

原文地址:https://www.jb51.cc/ruby/273286.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐