Heroku Invalid database_url with mongohq

563 Views Asked by At

Im trying to deploy my application in heroku. My app uses mongohq for the database. I have added the respective add-on to my app.

When deploying the app i get this error.

Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
   Running: rake assets:precompile
   ** Notice: The native BSON extension was not loaded. **
   For optimal performance, use of the BSON extension is recommended.
   To enable the extension make sure ENV['BSON_EXT_DISABLED'] is not set
   and run the following command:
   gem install bson_ext
   If you continue to receive this message after installing, make sure that
   the bson_ext gem is in your load path.
   rake aborted!
   Invalid DATABASE_URL
   (erb):9:in `rescue in <main>'
   (erb):6:in `<main>'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application/configuration.rb:106:in `database_configuration'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/railtie.rb:174:in `block (2 levels) in <class:Railtie>'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:27:in `each'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/railtie.rb:173:in `block in <class:Railtie>'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
   /tmp/build_3o2y20a7ewhl/config/environment.rb:5:in `<top (required)>'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:249:in `block in run_tasks_blocks'
   /tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
   Tasks: TOP => environment
   (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !

 !     Push rejected, failed to compile Ruby/Rails app

It looks like is trying to write the DATABASE_URL in database.yml but i don't use one. I just use monogoid.yml and set the proper ENV var MONGOHQ_URL.

Do i need to setup any configuration so heroku can detect i'm using mongo as my database?

EDIT:

My mongoid.yml file looks like this.

production:
    sessions:
     default:
      uri: <%= ENV['MONGOHQ_URL'] %>

I have read that article, i'm following those steps.

1

There are 1 best solutions below

1
On

In case anyone is going through the same, i had in my application.rb a reference to active record that i needed to take away:

#require "active_record/railtie"

Also double check your environments files, in some cases you could have some active_record configuration code.

Hope it helps.