Error running ar_sendmail when using Alternate Mail Storage #6

Open
ares opened this Issue Jul 27, 2010 · 6 comments

Comments

Projects
None yet
2 participants

ares commented Jul 27, 2010

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 commented Jul 27, 2010

I'm using adzap-ar_mailer (2.1.8)

Owner

adzap commented Jul 27, 2010

What version of Rails?

ares commented Jul 28, 2010

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

ares commented Jul 28, 2010

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.

Owner

adzap commented Jul 28, 2010

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.

ares commented Jul 29, 2010

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment