class Advertiser < ActiveRecord::Base
devise :database_authenticatable, :registerable,:recoverable, :rememberable, :trackable, :validatable,:confirmable
acts_as_paranoid
end
I added the Devise gem first without the confirmable option. Then I later added the confirmable option with this migration:
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
When I run migration it gives an error
PG::UndefinedColumn: ERROR: column advertisers.deleted_at does not exist
LINE 1: ...onfirmed_at" = '2015-11-05 06:24:26.513079' WHERE "advertise...
Change the migration file like this:
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
For further reference see devise