未定义的局部变量或#User的“confirmation_at”方法 [英] undefined local variable or method `confirmed_at' for #User

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

问题描述

我正在使用Rails 3.有可能的重复此处。但是它并没有解决我的问题,也没有解决我的问题。



我的迁移如下

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

我有 devise c code code code code code code code code $ c db:migrate 不输出。我的注册页面出现错误:

 未定义的局部变量或方法'confirmation_at'for #User 

有人有线索?

解决方案

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



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.Then

  rake db:migrate 


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

My migration is as follows

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

I do have devise :confirmable added in User model.

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

undefined local variable or method 'confirmed_at' for #User

Anybody has a clue?

解决方案

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

1.Run command:

rails g migration add_confirmable_to_devise_v1

2.In the migration file:

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

3.Then

rake db:migrate

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆