Code Climate

Acts As Mailable

Allows for email_templates to be added to multiple and different models.

Installation :

Add the following line to your Gemfile

gem 'acts_as_mailable'

Generator

Basic Email Templates

rails g email_template

And if you wish to keep a record of emails sent_at etc:

rails g mailable_template

Then migrate your database:

rake db:migrate

Usage

Make your ActiveRecord model act as commentable:

class Organisation < ActiveRecord::Base
  acts_as_mailable
end

Add a comment to a model instance:

mailable = Organisation.create(name: "King")
mailable.email_templates.create(name: "First template.", subject: "This is the first template.", body: "This is the body of the first template.")

Fetch email_templates for a mailable model:

organisation = Organisation.find(1)
organisation.email_templates.create(name: "First template.", subject: "This is the first template.", body: "This is the body of the first template.")

Copyright (c) 2013 Lachlan Priest. See LICENSE.txt for further details.