Skip to content

Instantly share code, notes, and snippets.

@rajcybage
Created August 12, 2013 13:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajcybage/6210925 to your computer and use it in GitHub Desktop.
Save rajcybage/6210925 to your computer and use it in GitHub Desktop.
#/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
#/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