require 'yaml' module ChangeManager class NotificationMailer < ActionMailer::Base CONFIG ||= YAML.load_file(File.join(Rails.root, 'config/change_manager_config.yml')) def construct_email(changes) @body = prepare_body(changes) mail( to: changes.first.target, from: changes.first.owner, subject: 'Recent Updates from ' + CONFIG['site_name'], ) end def send_email(constructed_email) constructed_email.deliver end def prepare_body(changes) header = '' body = '' footer = '
Change OwnerChange ContextChangeTime
' changes.each do |change| body += '' + change.owner + '' + change.context + '' + change.change_type + '' + change.created_at.to_s + '' end content = header + body + footer end end end