Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

Commit

Permalink
created a new user mailer
Browse files Browse the repository at this point in the history
  • Loading branch information
mhseiden committed Sep 5, 2012
1 parent 4cffe2e commit 3fab8d6
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ gem 'haml', '3.1.6'
gem 'sass-rails', '~> 3.2.3'
gem 'uglifier', '>= 1.0.3'

# Email
gem 'letter_opener', '0.0.2'

# Application Logic Gems
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'declarative_authorization', '0.5.5'
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ GEM
activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.3.2)
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.0)
Expand All @@ -50,6 +51,10 @@ GEM
koala (1.5.0)
faraday (~> 0.7)
multi_json (~> 1.3)
launchy (2.1.2)
addressable (~> 2.3)
letter_opener (0.0.2)
launchy
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
Expand Down Expand Up @@ -118,6 +123,7 @@ DEPENDENCIES
haml (= 3.1.6)
httparty
koala
letter_opener (= 0.0.2)
mysql2 (= 0.3.11)
net-ldap
rails (= 3.2.6)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/ajax/ajax_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def ajax_exception_wrapper
begin
yield
rescue Exception => e
e.backtrace.each { |l| logger.error l } if Rails.env.development?
msg = Rails.env.production? ? default_exception_message : e.message
respond_with_json(400, msg, e)
end
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/ajax/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ def sign_up_by_email_and_type
user.user_type = UserType.find_by_type_name params[:user_type][:type_name]
user.set_fullname_from_ldap if user.is_student?

user.save!
#user.save!

UserMailer.new_user(user).deliver

response_text = user.first_name.empty? ? "Thank you for registering!" : "Thank you for registering, #{user.first_name}!"
respond_with_json 200, response_text, {}
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ApplicationController < ActionController::Base
# Handler for redirecting to the 404 page
def render_404(error)
@error_message = error
logger.error error.backtrace if Rails.env.development?
render template: "static_pages/error", status: 404
end

Expand Down
10 changes: 10 additions & 0 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class UserMailer < ActionMailer::Base

default from: "no-reply@michiganhackers.org"

def new_user(user)
@user = user
mail(to: user.email, subject: "Welcome to Michigan Hackers")
end

end
13 changes: 13 additions & 0 deletions app/views/user_mailer/new_user.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
%table{style: "font-weight:lighter;line-height:18px;margin: 0px auto; font-family:sans-serif;", width: "760px", height: "100px"}
%trbody
%tr
%td
%div{style: "border-bottom: 2px solid #FF3C00;padding:20px 0px 10px 0px;"}
%img{style: "vertical-align:middle;height:60px;display:inline-block;", src: "http://michiganhackers.org/assets/images/logo_orange.png"}
%h1{style: "margin:0px;font-size:60px;padding-left:10px;vertical-align:middle;display:inline-block;color: #FF3C00"}= "Michigan Hackers"
%tr
%td
%div{style: "width:1px;height:20px;"}
%tr
%td
%p= "Thank you for registering with Michigan Hackers! The rest of the copy goes here."
4 changes: 4 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5

# Setting up the action mailer to use letter_opener
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.smtp_settings = {}

end

0 comments on commit 3fab8d6

Please sign in to comment.