zapnap/resque_mailer — Issue #21: Rails app won't start in production -- problem with config/initializers/resque_mailer.rb
Author: jobster
Created: 2012-02-11 03:07:22+00:00
State: open

I have an issue in my production environment that crashes my Rails app upon startup (the app never loads up fully). I'm not sure why this gem is the cause, but I do know that it is the source of the problem. **Before this issue started**, my app was working fine in production and this is what my `config/initializers/resque_mailer.rb` file looked like:

#config/intializers/resque_mailer.rb
Resque::Mailer.default_queue_name = "email"
Resque::Mailer.excluded_environments = [ :development, :test ]

# Setup a default mailer class that sends mail asynchronously
class AsyncMailer < ActionMailer::Base
include Resque::Mailer
end

After my subsequent deploy broke the app, I tried to figure out what I had changed that could have caused the issue. After a lot of testing, gnashing of teeth, and many many git reverts, I was able to pinpoint the problem to one commit that changed the `config/initializers/resque_mailer.rb` file to the following:

#config/intializers/resque_mailer.rb
Resque::Mailer.default_queue_name = "email"
Resque::Mailer.excluded_environments = [ :development, :test ]

In essence, all I did was remove the `AsyncMailer` class, which I wasn't using anyway. However, when I try to deploy, the app won't start up and I get the following error:

You can no longer call ActionMailer::Base.default_url_options directly. You need to set config.action_mailer.default_url_options. If you are using ActionMailer standalone, you need to include the routing url_helpers directly.

This stems from `ActionMailer::Base` line 788 (in Rails 3.0.10), and I can't figure out why it's throwing this error. Nowhere in my code do I set `ActionMailer::Base.default_url_options` directly.

Now, the bright side is that I can revert my changes (and I already have, in production) and get the app working again. However, I **never** used the `AsyncMailer` class, instead I always added the include directly to whatever mailer needed it. So I would prefer not to have to add those lines back in, because it seems weird to me to have to include extra, unused classes in my app. Moreover, I'm absolutely confounded as to how these lines could be causing the problem, but I'm also absolutely sure that they are in fact the cause of this issue. Any help or insight would be greatly appreciated!

Note that I CANNOT reproduce this error in development, no matter what I do.
My production environment runs Ruby 1.9.3, Rails 3.0.10, Passenger 3.0.11 and nginx 1.0.10 and the latest version of the resque_mailer gem.