Rails Devise: after_confirmation

donald picture donald · Dec 29, 2010 · Viewed 12.3k times · Source

Is there a way to create a after_confirmation :do_something ?

The goal is to send an e-mail after the user confirms using Devise :confirmable.

Answer

Blue Smith picture Blue Smith · Dec 17, 2013

I'm using Devise 3.1.2, it has a placeholder method after_confirmation which is called after the confirmation finished successfully. We just need to override this method in User model.

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

  # Override Devise::Confirmable#after_confirmation
  def after_confirmation
    # Do something...
  end
end

See: Devise 3.5.9 Source Code: https://github.com/plataformatec/devise/blob/d293e00ef5f431129108c1cbebe942b32e6ba616/lib/devise/models/confirmable.rb