Class: CustomEmails::Mailer
- Inherits:
-
ActionMailer::Base
- Object
- ActionMailer::Base
- CustomEmails::Mailer
- Defined in:
- app/mailers/custom_emails/mailer.rb
Instance Method Summary collapse
- #custom_email_to(dest, kind_name, emailable = nil, options = {}) ⇒ Object
- #email_to(email, dest, options = {}) ⇒ Object
Instance Method Details
#custom_email_to(dest, kind_name, emailable = nil, options = {}) ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/mailers/custom_emails/mailer.rb', line 4 def custom_email_to(dest, kind_name, emailable=nil, ={}) locale = [:locale] || CustomEmails.default_locale kind = EmailKind.find_by!(name: kind_name) email = Email.find_by!(kind_id: kind.id, emailable_id: emailable.try(:id), locale: locale) email_to(email, dest, ) end |
#email_to(email, dest, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/mailers/custom_emails/mailer.rb', line 12 def email_to(email, dest, ={}) context = [:context] || {} sender = [:from] || CustomEmails.default_from subject = email.interpolated_subject(context) mail(to: dest, from: sender, subject: subject) do |format| format.html { email.interpolated_content_html(context) } if email.content_html.present? format.text { email.interpolated_content_text(context) } end end |