Created
May 20, 2011 01:38
-
-
Save benoror/982181 to your computer and use it in GitHub Desktop.
devise_invitable: Confirm after set password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Yes, but it will send welcome message BEFORE confirming (or accepting the invitation if that's the case) the account.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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