Deploying VoltRb app on Heroku with persistence from MongoLab

103 Views Asked by At

I'm trying to get a new/blank volt (0.9.5) app into production on Heroku following the instructions on the Volt docs page.

The application deploys successfully until I try and add the Mongo database.

The below creates a new MongoLab database and sets a connection URI to the MONGOLAB_URI variable.

 $ heroku addons:create mongolab

I thought all I had to do was copy the below into my config/app.rb file and replace the 'MONGOHQ_URL' with 'MONGOLAB_URI'.

config.db_driver = 'mongo'
config.db_name = (config.app_name + '_' + Volt.env.to_s)

if ENV['MONGOHQ_URL'].present?
  config.db_uri = ENV['MONGOHQ_URL'] # you will have to set this on heroku
else
  config.db_host = 'localhost'
  config.db_port = 27017
end

But this is resulting in an application error and the log is showing the below...

[ERROR] Error adding listener: #<Mongo::AuthenticationError: Failed to authenticate user

Can anyone point me in the right direction?

2

There are 2 best solutions below

3
Ryan On

This isn't an answer, but you should be able to run heroku config to see what ENV's are set for the dyno. Does that show the ENV?

0
Luke Cassar On

Some other users suggested that the issue was to do with an outdated version of the volt-mongo gem which was, "using an old version of the Mongo Ruby driver." I have since upgraded to the latest version (currently 0.1.4) and everything seems to be working ok with the database.