I'm getting the following error when trying to use the :confirmable module of Devise:
NameError (undefined local variable or method `confirmed_at' for #<AdminUser:0x007f27841d0f30>)
My model:
class AdminUser < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,:recoverable, :rememberable, :trackable, :validatable, :confirmable
after_create { |admin| admin.send_reset_password_instructions }
def password_required?
new_record? ? false : super
end
end
I want to send a confirmation email when AdminUser is created.
It is not enough to merely add the :confirmable option in the model, you'll also need to add the columns required by Devise into your database table.
Assuming you are using a model AdminUser:
class AddConfirmableToDevise < ActiveRecord::Migration
def self.up
add_column :admin_users, :confirmation_token, :string
add_column :admin_users, :confirmed_at, :datetime
add_column :admin_users, :confirmation_sent_at, :datetime
add_column :admin_users, :unconfirmed_email, :string
add_index :admin_users, :confirmation_token, :unique => true
end
def self.down
remove_index :admin_users, :confirmation_token
remove_column :admin_users, :unconfirmed_email
remove_column :admin_users, :confirmation_sent_at
remove_column :admin_users, :confirmed_at
remove_column :admin_users, :confirmation_token
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With