Sha256: 8ec3ec4c8f37c552fb2bcebb46748101b949d1452930494e73e439c7c820e346
Contents?: true
Size: 898 Bytes
Versions: 20
Compression:
Stored size: 898 Bytes
Contents
module EffectiveEmailTemplatesHelper # We are given a form to essentially send an email def effective_email_review_fields(form, template_name, mail = nil) raise('expected a mail object') if mail && !mail.kind_of?(ActionMailer::MessageDelivery) raise('expected form.object to respond to email_review') unless form.object.respond_to?(:email_review) email_review = form.object.email_review unless email_review&.template_name == template_name.to_s email_template = Effective::EmailTemplate.where(template_name: template_name).first! email_review = Effective::EmailReview.build(email_template: email_template) if mail.present? email_review.body = mail.message.body email_review.subject = mail.message.subject end end render(partial: 'effective/email_reviews/fields', locals: { email_review: email_review, form: form }) end end
Version data entries
20 entries across 20 versions & 1 rubygems