Multidb should be initialized after ActiveRecord in Rails #1

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants

antage commented Jan 28, 2013

When I try to use multidb with rails application I got following error:

ActiveRecord::ConnectionNotEstablished
/home/antage/workspace/app/.gems/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:167:in `connection_pool'
/home/antage/workspace/app/.gems/ruby/1.9.1/gems/ar-multidb-0.1.6/lib/multidb/configuration.rb:6:in `configure!'
/home/antage/workspace/app/.gems/ruby/1.9.1/gems/ar-multidb-0.1.6/lib/multidb.rb:12:in `install!'
/home/antage/workspace/app/.gems/ruby/1.9.1/gems/ar-multidb-0.1.6/lib/multidb.rb:28:in `<top (required)>'
/home/antage/workspace/app/.gems/ruby/1.9.1/gems/ar-multidb-0.1.6/lib/ar-multidb.rb:1:in `require'
/home/antage/workspace/app/.gems/ruby/1.9.1/gems/ar-multidb-0.1.6/lib/ar-multidb.rb:1:in `<top (required)>'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
/home/antage/workspace/app/config/application.rb:13:in `<top (required)>'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/antage/workspace/app/Rakefile:4:in `<top (required)>'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load_rakefile'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rake/application.rb:501:in `raw_load_rakefile'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rake/application.rb:82:in `block in load_rakefile'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rake/application.rb:81:in `load_rakefile'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rake/application.rb:65:in `block in run'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/home/antage/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/rake/application.rb:63:in `run'
/home/antage/.rbenv/versions/1.9.3-p327/bin/rake:32:in `<main>'

It occurs due to multidb trying to get connection_pool before it's initialized.
I added lazy hook to ensure multidb extend activerecord after activerecord's initialized.

Owner

atombender commented Jan 28, 2013

Thanks for this. I need to make sure still works with Rails 2.3.15 (which we use with Multidb in production) before I can merge it.

antage commented Jan 28, 2013

This PR doesn't work with rails 2.3 and it seems multidb doesn't work with rails 3.x. Sorry I didn't find that information in README. Ignore this PR.

antage closed this Jan 28, 2013

Owner

atombender commented Jan 28, 2013

The intention is certainly to have it work with 3.x (most of our apps are on 3.2). I don't remember if I spent any work on it, but should be trivial to fix.

atombender reopened this Jan 28, 2013

Owner

atombender commented Feb 2, 2014

I have changed how Multidb initializes to avoid explicit setup on startup. Instead, Multidb configures itself when it's first needed.

atombender closed this Feb 2, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment