0

运行 rake db:migrate 时出现以下错误:

undefined method `confirmable' for #<ActiveRecord::ConnectionAdapters::Table:0x6d448e8>
c:/java/RubyProjects/myproject/db/migrate/20111202225103_make_user_confirmable.rb:4:in `block in change'
c:/java/RubyProjects/myproject/db/migrate/20111202225103_make_user_confirmable.rb:3:in `change'
c:in `migrate'
Tasks: TOP => db:migrate

用户.rb:

class User < ActiveRecord::Base

  devise :database_authenticatable, :registerable, 
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me

  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :confirmable

  ...

end

20111202225103_make_user_confirmable.rb:

class MakeUserConfirmable < ActiveRecord::Migration
  def change
    change_table(:users) do |t|
      t.confirmable
    end

    add_index :users, :confirmation_token,   :unique => true
  end
end

不知道还要做什么。。

请帮忙。

4

1 回答 1

3

编辑:
如何:向用户添加:可确认

PS
没有像rails迁移这样的类型confirmable,所以迁移失败。
但是,如果您仍想向confirmable用户表添加列:

class MakeUserConfirmable < ActiveRecord::Migration
  def change
    change_table(:users) do |t|
      t.boolean :confirmable, :default => false
    end
  end
end
于 2013-04-14T07:01:21.563 回答