Skip to content

Instantly share code, notes, and snippets.

@benoror
Created May 20, 2011 01:38
Show Gist options
  • Save benoror/982181 to your computer and use it in GitHub Desktop.
Save benoror/982181 to your computer and use it in GitHub Desktop.
devise_invitable: Confirm after set password
class User < ActiveRecord::Base
devise :invitable, :database_authenticatable, :registerable, :recoverable,
:rememberable, :confirmable, :validatable, :encryptable
# ...
# devise confirm! method overriden
def confirm!
welcome_message
super
end
# devise_invitable accept_invitation! method overriden
def accept_invitation!
self.confirm!
super
end
# devise_invitable invite! method overriden
def invite!
super
self.confirmed_at = nil
self.save
end
private
def welcome_message
UserMailer.welcome_message(self).deliver
end
end
@alexandru-calinoiu
Copy link

I think rails 3 allows you to do the following:
after_create :send_welcome_email
.....

private

def send_welcome_email
UserEmailer.welcome_email(self).deliver
end

@benoror
Copy link
Author

benoror commented Jun 5, 2011

Yes, but it will send welcome message BEFORE confirming (or accepting the invitation if that's the case) the account.

@benoror
Copy link
Author

benoror commented May 26, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment