librelist archives

« back to archive

Multi DB Support in Rails

Multi DB Support in Rails

From:
Matthew Brookes
Date:
2015-05-15 @ 16:14
Hi All,

I’m trying to configure a new Rails (4.2.1) project in a way that the
databases aren't hard-coded through config/database.yml, but when I
put:  @results_db
= CouchPotato.use('results8’) in my controller, I get:

undefined method `use' for CouchPotato:Module

This works fine in a standalone script, so suspect it’s something I’ve
missed. Any suggestions appreciated!

Thanks!
Matt.

Full stack trace:

app/controllers/results_controller.rb:4:in `<class:ResultsController>'
<http://localhost:3000/results#>
app/controllers/results_controller.rb:1:in `<top (required)>'
<http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/dependencies.rb:457:in `load'
<http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/dependencies.rb:457:in `block
in load_file' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/dependencies.rb:647:in
`new_constants_in' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/dependencies.rb:456:in
`load_file' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/dependencies.rb:354:in
`require_or_load' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/dependencies.rb:494:in
`load_missing_constant' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/dependencies.rb:184:in
`const_missing' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/inflector/methods.rb:261:in
`const_get' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/inflector/methods.rb:261:in
`block in constantize' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/inflector/methods.rb:259:in
`each' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/inflector/methods.rb:259:in
`inject' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/inflector/methods.rb:259:in
`constantize' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/dependencies.rb:566:in `get'
<http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/dependencies.rb:597:in
`constantize' <http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:70:in
`controller_reference' <http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:60:in
`controller' <http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:39:in
`serve' <http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:43:in `block
in serve' <http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:in `each'
<http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:in `serve'
<http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:819:in
`call' <http://localhost:3000/results#>
rack (1.6.1) lib/rack/etag.rb:24:in `call' <http://localhost:3000/results#>
rack (1.6.1) lib/rack/conditionalget.rb:25:in `call'
<http://localhost:3000/results#>
rack (1.6.1) lib/rack/head.rb:13:in `call' <http://localhost:3000/results#>
actionpack (4.2.1)
lib/action_dispatch/middleware/params_parser.rb:27:in `call'
<http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/middleware/flash.rb:260:in
`call' <http://localhost:3000/results#>
rack (1.6.1) lib/rack/session/abstract/id.rb:225:in `context'
<http://localhost:3000/results#>
rack (1.6.1) lib/rack/session/abstract/id.rb:220:in `call'
<http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/middleware/cookies.rb:560:in
`call' <http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:29:in
`block in call' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in `call'
<http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in
`_run_callbacks' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/callbacks.rb:776:in
`_run_call_callbacks' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/callbacks.rb:81:in
`run_callbacks' <http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in
`call' <http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/middleware/reloader.rb:73:in
`call' <http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/middleware/remote_ip.rb:78:in
`call' <http://localhost:3000/results#>
actionpack (4.2.1)
lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
<http://localhost:3000/results#>
web-console (2.1.2) lib/web_console/middleware.rb:37:in `call'
<http://localhost:3000/results#>
actionpack (4.2.1)
lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
<http://localhost:3000/results#>
railties (4.2.1) lib/rails/rack/logger.rb:38:in `call_app'
<http://localhost:3000/results#>
railties (4.2.1) lib/rails/rack/logger.rb:20:in `block in call'
<http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in
`block in tagged' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/tagged_logging.rb:26:in
`tagged' <http://localhost:3000/results#>
activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in
`tagged' <http://localhost:3000/results#>
railties (4.2.1) lib/rails/rack/logger.rb:20:in `call'
<http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/middleware/request_id.rb:21:in
`call' <http://localhost:3000/results#>
rack (1.6.1) lib/rack/methodoverride.rb:22:in `call'
<http://localhost:3000/results#>
rack (1.6.1) lib/rack/runtime.rb:18:in `call' <http://localhost:3000/results#>
activesupport (4.2.1)
lib/active_support/cache/strategy/local_cache_middleware.rb:28:in
`call' <http://localhost:3000/results#>
rack (1.6.1) lib/rack/lock.rb:17:in `call' <http://localhost:3000/results#>
actionpack (4.2.1) lib/action_dispatch/middleware/static.rb:113:in
`call' <http://localhost:3000/results#>
rack (1.6.1) lib/rack/sendfile.rb:113:in `call' <http://localhost:3000/results#>
railties (4.2.1) lib/rails/engine.rb:518:in `call'
<http://localhost:3000/results#>
railties (4.2.1) lib/rails/application.rb:164:in `call'
<http://localhost:3000/results#>
rack (1.6.1) lib/rack/lock.rb:17:in `call' <http://localhost:3000/results#>
rack (1.6.1) lib/rack/content_length.rb:15:in `call'
<http://localhost:3000/results#>
rack (1.6.1) lib/rack/handler/webrick.rb:89:in `service'
<http://localhost:3000/results#>

/Users/matthew_brookes/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:138:in
`service' <http://localhost:3000/results#>

/Users/matthew_brookes/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:94:in
`run' <http://localhost:3000/results#>

/Users/matthew_brookes/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/server.rb:294:in
`block in start_thread' <http://localhost:3000/results#>