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

Version Path
effective_email_templates-1.9.0 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.8.0 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.7.0 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.6.0 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.5.1 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.5.0 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.4.1 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.4.0 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.3.0 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.2.3 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.2.2 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.2.1 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.2.0 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.1.4 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.1.3 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.1.2 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.1.1 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.1.0 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.0.13 app/helpers/effective_email_templates_helper.rb
effective_email_templates-1.0.12 app/helpers/effective_email_templates_helper.rb