#User 的未定义局部变量或方法“confirmed

编程入门 行业动态 更新时间:2024-10-10 23:16:12
本文介绍了#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

本文发布于:2023-10-27 23:47:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534882.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   局部   未定义   方法   User

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!