Skip to content
Senarii edited this page May 21, 2020 · 1 revision

Reasoning

To give applicants updates on their application status and confirmation on certain tasks, in our case successful creation of an account and submission of an application.

Action Mailer

The entire emailing feature is handle through Action Mailer, Rails bulit-in way to handle sending and receiving email. The Action Mailer has two main components the view, which contains how the email will look and the mailer, which handles all logistic of the emailing (eg. what email to sent to from, where the email are going, etc... )

Mailer-Preview

Previewing Sent Email

To preview any of the sent email during development, go to test/mailers/previews/user_mailer_preview.rb. Click on the link (cmd + click on mac and ctrl + click on windows) in the comments and it should lead you to a very basic html pages with some hyperlinks. Each of the hyperlinks correspond to one of the method in user_mailer_preview.rb. Clicking on any of those link will lead to their respective email previews.

Adding New Preview

To add a new preview simply create a new method in the preview that calls your desired mailer method.

Helpful Tip:

  • You do not have send an email every single time you make a change to the email view, you can just refresh the preview page for that email.

Implemention

For the most part I follow the guide linked in the helpful sources section to get start with Action Mailer. So if you have any question about how to create the new mailer files or how to implemenet new methods, please check out the link below.

Confirmation Email

There are only two times when we sent out confirmation email and that is when the user creates their HackUMass account and when they submit their HackUMass application. Both of these confirmation cases were implements in the same way, in which all the code pretaining to sending the email can be found in their respective model files.

Breakdown of code

The code below shows the generic layout of what you would find in the model files

after_create :method_name

def method_name
  # code to call mailer
end

English Translation of code above: After successfully finishing the create method, call and excute the method name.

Update Email

All email pertaining to application status updated are excuted in the status_upated method, which is located in the event_applications_controller.rb.

Helpful Sources