Ruby on rails 未定义的局部变量或方法“在'处确认”;对于#<;用户:0x8f53b44>;

Ruby on rails 未定义的局部变量或方法“在'处确认”;对于#<;用户:0x8f53b44>;,ruby-on-rails,ruby,devise,devise-confirmable,Ruby On Rails,Ruby,Devise,Devise Confirmable,我知道其他人问了这个问题,但答案并没有解决我的问题 我在尝试注册功能时遇到此错误:“未定义的局部变量或方法‘confirmed_at’for#” 我的迁移如下所示: class DeviseCreateUsers < ActiveRecord::Migration def change create_table(:users) do |t| ## Customization t.string :name ## Database authent

我知道其他人问了这个问题,但答案并没有解决我的问题

我在尝试注册功能时遇到此错误:
“未定义的局部变量或方法‘confirmed_at’for#”

我的迁移如下所示:

class DeviseCreateUsers < ActiveRecord::Migration
  def change
    create_table(:users) do |t|
      ## Customization
      t.string :name
      ## Database authenticatable
      t.string :email,              :null => false, :default => ""
      t.string :encrypted_password, :null => false, :default => ""

      ## Recoverable
      t.string   :reset_password_token
      t.datetime :reset_password_sent_at

      ## Rememberable
      t.datetime :remember_created_at

      ## Trackable
      t.integer  :sign_in_count, :default => 0, :null => false
      t.datetime :current_sign_in_at
      t.datetime :last_sign_in_at
      t.string   :current_sign_in_ip
      t.string   :last_sign_in_ip

      ## Confirmable
      t.string   :confirmation_token
      t.datetime :confirmed_at
      t.datetime :confirmation_sent_at
      t.string   :unconfirmed_email # Only if using reconfirmable

      ## Lockable
      # t.integer  :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
      # t.string   :unlock_token # Only if unlock strategy is :email or :both
      # t.datetime :locked_at


      t.timestamps
    end

    add_index :users, :email,                :unique => true
    add_index :users, :reset_password_token, :unique => true
    # add_index :users, :confirmation_token,   :unique => true
    # add_index :users, :unlock_token,         :unique => true
  end
end
classdeveliecCreateUsersfalse,:default=>
t、 字符串:加密密码,:null=>false,:default=>
##可恢复
t、 字符串:重置密码\u令牌
t、 日期时间:重置密码发送时间
##难忘的
t、 datetime:记住在
##可追踪
t、 整数:计数中的符号,:default=>0,:null=>false
t、 日期时间:当前登录时间
t、 日期时间:上次登录时间
t、 字符串:ip中的当前\u符号\u
t、 字符串:ip中的最后\u签名\u
##可证实
t、 字符串:确认令牌
t、 日期时间:已确认
t、 日期时间:确认发送至
t、 字符串:未确认的电子邮件#仅当使用可再确认
##可锁
#t.integer:failed_尝试,:default=>0,:null=>false#仅当锁定策略为:failed_尝试时
#t.string:unlock_token#仅当解锁策略为:email或:两者皆有时
#t.datetime:locked_在
t、 时间戳
结束
添加索引:users,:email,:unique=>true
添加索引:users,:reset\u password\u token,:unique=>true
#添加索引:users,:confirmation\u token,:unique=>true
#添加索引:users,:unlock\u token,:unique=>true
结束
结束
我在用户模型中添加了
design:confirmable


我做错了什么?非常感谢

我也遇到了同样的问题,@tagCincy的回答解决了我的问题。 您只需在迁移中取消对索引行的注释

添加索引:用户,:确认\u令牌,唯一:true


你运行了迁移,重新加载了你的模型?你的schema.rb看起来像什么?与@Doon的问题相同,在添加可确认模块后,你是否运行了
rake db:migrate
。另外,请确保取消对确认令牌上的索引声明的注释:
add\u index:users,:confirmation\u token,:unique=>true
我在添加可确认模块之前运行了rake db:migrate,因此我删除并再次运行了它,但现在我收到了此错误:“550无法从指定地址接收”。我想我应该更改电子邮件地址?