0

I am using the Mandrill api gem to send scheduled emails with the delayed jobs gem.

When the delayed job is executed by the worker the job is crashing at the line which creates the mandrill message with the following error:

DailyMailJob failed with NameError: uninitialized constant Mandrill::API

If I execute this job from the rails console it runs fine.

Why does this job not work when running from the worker?

startupsmith
  • 5,554
  • 10
  • 50
  • 71
  • Rails allows you to not have to think about and be explicit about your dependencies, it just loads everything when you start up a server or console. The worker process may not be doing this, and so you may need to explicitly require the Mandrill library in the file where you define your DailyMailJob class. It's good practice anyways to be explicit about your dependencies. – Amit Kumar Gupta Jun 01 '13 at 06:14
  • I have explicitly required mandrill with "require 'mandrill'" at the top of the job file... Still not working. – startupsmith Jun 01 '13 at 21:55
  • Hmmmm, sorry that didn't help. It's hard to say more without seeing some relevant code. – Amit Kumar Gupta Jun 04 '13 at 20:56

1 Answers1

0

I managed to fix the issue by installing the gem into the computer rather than just into the app.

The command I used to do this was:

gem install mandrill=api

mah
  • 39,056
  • 9
  • 76
  • 93
startupsmith
  • 5,554
  • 10
  • 50
  • 71