From c8551197ec12dd92f4730a82bf2dbe2998f6fbed Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 29 Apr 2014 11:41:20 -0700 Subject: [PATCH] Implement RSVP mailer --- app/controllers/rsvps_controller.rb | 1 + app/mailers/rsvp_mailer.rb | 11 +++++++++++ app/views/rsvp_mailer/rsvp_email.html.erb | 3 +++ 3 files changed, 15 insertions(+) create mode 100644 app/mailers/rsvp_mailer.rb create mode 100644 app/views/rsvp_mailer/rsvp_email.html.erb diff --git a/app/controllers/rsvps_controller.rb b/app/controllers/rsvps_controller.rb index b414315..c3bc261 100644 --- a/app/controllers/rsvps_controller.rb +++ b/app/controllers/rsvps_controller.rb @@ -54,6 +54,7 @@ def create respond_to do |format| if @rsvp.save + RSVPMailer.rsvp_email(current_user, @rsvp.event).deliver format.html { redirect_to(@event, :notice => 'Thanks for RSVPing! See you there!') } format.xml { render :xml => @rsvp, :status => :created, :location => @rsvp } else diff --git a/app/mailers/rsvp_mailer.rb b/app/mailers/rsvp_mailer.rb new file mode 100644 index 0000000..ed2fe9c --- /dev/null +++ b/app/mailers/rsvp_mailer.rb @@ -0,0 +1,11 @@ +class RSVPMailer < ActionMailer::Base + def rsvp_email(user, event) + @user = user + @event = event + mail( + :from => "no-reply@hkn.eecs.berkeley.edu", + :to => user.email, + :subject => "[HKN] RSVP Notification" + ) + end +end diff --git a/app/views/rsvp_mailer/rsvp_email.html.erb b/app/views/rsvp_mailer/rsvp_email.html.erb new file mode 100644 index 0000000..16ffff8 --- /dev/null +++ b/app/views/rsvp_mailer/rsvp_email.html.erb @@ -0,0 +1,3 @@ +<%= @user.full_name %>, + +You have RSVP'd for <%= @event.title %>, starting at <%= @event.start_time.strftime('%a %m/%d/%y %I:%M%p') %>.