Skip to content

Commit

Permalink
+ Add welcome message email after sign up
Browse files Browse the repository at this point in the history
  • Loading branch information
williamn committed Aug 16, 2012
1 parent e8f09b0 commit 3906d92
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nifty-blog/app/mailers/user_mailer.rb
@@ -0,0 +1,9 @@
class UserMailer < ActionMailer::Base
default from: "no-reply@example.com"

def welcome_email(user)
@user = user
@url = "http://localhost:3000/sign_in"
mail(:to => user.email, :subject => "Welcome blogger!")
end
end
5 changes: 5 additions & 0 deletions nifty-blog/app/models/user.rb
Expand Up @@ -7,4 +7,9 @@ class User < ActiveRecord::Base

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation

# Tell the UserMailer to send a welcome Email after create
after_create do |user|
UserMailer.welcome_email(user).deliver
end
end
13 changes: 13 additions & 0 deletions nifty-blog/app/views/user_mailer/welcome_email.html.erb
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>Welcome to example.com, blogger.</h1>
<p>
To login to the site, just follow this link: <%= @url %>.
</p>
<p>Thanks for joining and have a great day!</p>
</body>
</html>
6 changes: 6 additions & 0 deletions nifty-blog/app/views/user_mailer/welcome_email.text.erb
@@ -0,0 +1,6 @@
Welcome to example.com, blogger
===============================================

To login to the site, just follow this link: <%= @url %>.

Thanks for joining and have a great day!

0 comments on commit 3906d92

Please sign in to comment.