ActiveCampaign / postmark-rails

Official integration library for using Rails and ActionMailer with the Postmark HTTP API
https://postmarkapp.com
MIT License
354 stars 47 forks source link

uninitialized constant PostmarkRails::TemplatedMailer error with postmark-rails 0.19.0 #67

Closed andrewlynch closed 2 years ago

andrewlynch commented 5 years ago

Based on the wiki entry regarding the templating implementation I wrote the following

class TestMailer < PostmarkRails::TemplatedMailer
  def welcome
    mail to: 'andrew@xxxxxx.xxx', postmark_template_alias: 'test'
  end
end

However, when called I get a NameError (uninitialized constant PostmarkRails::TemplatedMailer).

When inheriting from ApplicationMailer and including PostmarkRails::TemplatedMailerMixin I have no such issues.

Slawikus commented 5 years ago

I have the same issue.

temochka commented 5 years ago

Ok, I see what’s going on. The gem requires ActionMailer to be fully loaded to function, so, unless ActionMailer::Base is loaded before the file that references PostmarkRails::TemplatedMailer, referencing it will cause an error. The workaround right now is to add the following to your templated mailer files:

require 'postmark-rails/templated_mailer'