Rails acts_as_paranoid 迁移在确认设计时给出错误

Rails acts_as_paranoid migration giving error on confirmation of devise

class Advertiser < ActiveRecord::Base
devise :database_authenticatable, :registerable,:recoverable, :rememberable, :trackable, :validatable,:confirmable

acts_as_paranoid    
end

我先添加了 Devise gem,但没有确认选项。然后我后来在这个迁移中添加了可确认的选项:

class AddConfirmableToDevise < ActiveRecord::Migration
def up
add_column :advertisers, :confirmation_token, :string
add_column :advertisers, :confirmed_at, :datetime
add_column :advertisers, :confirmation_sent_at, :datetime

add_index :advertisers, :confirmation_token, :unique => true

Advertiser.update_all(:confirmed_at => Time.now)

end
end

当我 运行 迁移时出现错误

PG::UndefinedColumn: ERROR:  column advertisers.deleted_at does not exist
LINE 1: ...onfirmed_at" = '2015-11-05 06:24:26.513079' WHERE "advertise...

像这样更改迁移文件:

class AddConfirmableToDevise < ActiveRecord::Migration
  def up
    add_column :advertisers, :confirmation_token, :string
    add_column :advertisers, :confirmed_at, :datetime
    add_column :advertisers, :confirmation_sent_at, :datetime
    add_index :advertisers, :confirmation_token, unique: true
    add_column :advertisers, :deleted_at, :time
    execute("UPDATE advertisers SET confirmed_at = NOW()")
  end

  def down
    remove_columns :advertisers, :confirmation_token, :confirmed_at, :confirmation_sent_at
  end 
end

如需进一步参考,请参阅 devise