ar_mailer icon indicating copy to clipboard operation
ar_mailer copied to clipboard

Error running ar_sendmail when using Alternate Mail Storage

Open ares opened this issue 14 years ago • 6 comments

I set another class in initializer and when ar_sendmail is run I got Unhandled exception undefined method `email_class=' for ActionMailer::Base:Class(NoMethodError):

ares avatar Jul 27 '10 08:07 ares

I'm using adzap-ar_mailer (2.1.8)

ares avatar Jul 27 '10 08:07 ares

What version of Rails?

adzap avatar Jul 27 '10 23:07 adzap

2.3.5, no easy way to update right now (even to 2.3.6)

ares avatar Jul 28 '10 06:07 ares

Solved! Problem: ar_sendmail.rb 251 begin 252 require 'config/environment' 253 require 'action_mailer/ar_mailer' 254 rescue LoadError

As you can see config/enviroment is loaded before action mailer actually got email_class accessors. You can add

require 'action_mailer/ar_mailer'

to the first line of your initializer so it gets these methods before you use them. Maybe you could update README.

ares avatar Jul 28 '10 14:07 ares

That require actually seems unnecessary as the gem/plugin should be loaded already after the environment loads. So I am not sure why this can't work without requiring ar_mailer at all.

adzap avatar Jul 28 '10 23:07 adzap

yes, it's strange when I run irb in rails app root and run require 'config/environment.rb' ActionMailer::Base.email_class = QueuedEmailMessage everything seems to work

I don't see why but that require helped. Are you able to reproduce this problem (e.g. on newer version of rails)

ares avatar Jul 29 '10 05:07 ares