0

I'm getting uninitialized constant Mandrill::API in my rails application. I've added mandrill-api in Gemfile and did bundle.
my irb and rail console showing different results for Mandrill.constants

irb
[:Error, :ValidationError, :InvalidKeyError, :PaymentRequiredError, :UnknownSubaccountError, :UnknownTemplateError, :ServiceUnavailableError, :UnknownMessageError, :InvalidTagNameError, :InvalidRejectError, :UnknownSenderError, :UnknownUrlError, :UnknownTrackingDomainError, :InvalidTemplateError, :UnknownWebhookError, :UnknownInboundDomainError, :UnknownInboundRouteError, :UnknownExportError, :IPProvisionLimitError, :UnknownPoolError, :NoSendingHistoryError, :PoorReputationError, :UnknownIPError, :InvalidEmptyDefaultPoolError, :InvalidDeleteDefaultPoolError, :InvalidDeleteNonEmptyPoolError, :InvalidCustomDNSError, :InvalidCustomDNSPendingError, :MetadataFieldLimitError, :UnknownMetadataFieldError, :Templates, :Exports, :Users, :Rejects, :Inbound, :Tags, :Messages, :Whitelists, :Ips, :Internal, :Subaccounts, :Urls, :Webhooks, :Senders, :Metadata, :API] which includes :API and works fine,

But when it comes in console,
[:Templates, :Exports, :Users, :Rejects, :Inbound, :Tags, :Messages, :Whitelists, :Ips, :Internal, :Subaccounts, :Urls, :Webhooks, :Senders, :Metadata]
this is what I am getting. any ways??

shajin
  • 3,214
  • 5
  • 38
  • 53
  • There are a lot of answered questions about is on StackOverflow: look [1](http://stackoverflow.com/questions/24582435/delayed-job-and-mandrill-uninitialized-constant-mandrillapi) and [2](http://stackoverflow.com/questions/16869292/gem-not-initializing-when-running-job-from-worker) and so on. – Eugene Tkachenko Feb 27 '15 at 10:36
  • @EugeneTkachenko I was not calling by using any scheduler method but direct way (from console with UserMailer.sample_method(1).deliver – shajin Feb 27 '15 at 11:08
  • what happens when you run Mandrill::API.new ? – mylescc Feb 27 '15 at 11:19
  • @mylescc I got the issue..answered to this question – shajin Mar 02 '15 at 06:34

1 Answers1

5

When we are using gem 'mandrill-api' in rails application we have to give like this in Gemfile

gem 'mandrill-api', require: 'mandrill'

And it worked well after this change.

shajin
  • 3,214
  • 5
  • 38
  • 53
  • 1
    The people at mandrillapp.com need to update their doc with this. – Shinta Jun 30 '15 at 18:57
  • 1
    I personally prefer to declare `require: 'mandrill'` in file where I use `Mandrill::API` (in my case it was in `mailer/application_mailer.rb` ), this way gives me expressiveness to my code – geoom Oct 30 '15 at 13:15