Created
August 12, 2013 13:44
-
-
Save rajcybage/6210925 to your computer and use it in GitHub Desktop.
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
#/app/mailers/user_mailer.rb | |
def welcome (current_user) | |
unless current_user.nil? | |
mail( | |
:from => "myid@gmail.com", | |
:to => current_user.email, | |
:subject => "Thank you for signing" | |
) | |
else | |
mail( | |
:from => "myid@gmail.com", | |
:to => "test@mail.com", | |
:subject => "Thank you for signing" | |
) | |
end | |
end | |
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
#/app/controllers/registration_controller.rb | |
def create | |
build_resource | |
if resource.valid? | |
begin | |
resource.transaction do | |
resource.save! | |
end | |
UserMailer.welcome(resource).deliver | |
flash[:notice] = "Successfully registered" | |
sign_in(resource) | |
respond_with resource, :location => after_sign_up_path_for(resource) | |
rescue ActiveRecord::RecordInvalid => invalid | |
flash[:notice] = " Please try again" | |
clean_up_passwords resource | |
respond_with resource | |
end | |
else | |
clean_up_passwords resource | |
respond_with resource | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment