Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection_pool is nil when using rails 2.3.x and loading foreigner via bundler #35

Closed
mczepiel opened this issue Oct 13, 2010 · 4 comments

Comments

@mczepiel
Copy link

Looks like same problem mentioned here: http://github.com/matthuhiggins/foreigner/issues/closed#issue/13

 /app/vendor/bundler_gems/gems/foreigner-0.9.0/lib/foreigner.rb:32:in `configured_adapter':NoMethodError: undefined method `spec' for nil:NilClass

I think the load_adapter! call is happening too early. Obviously for 2.x we're skipping the Railtie block and immediately loading the adapter. Perhaps the problem is that I'm using bundler and not config.gem so the gem is being required before rails is fully initialized.

Manually calling Foreigner.load_adapter! in a config.after_initialize block in the environment.rb works fine provided I force the gem to only call that method if ActiveRecord::Base.connection_pool is available.

Quick fix would be to add this to the Rails 2 loading of foreigner and leaving it up to the developers to manually call this after_initialize unless you know of a way to set it up to happen after initialize once we know the pool isn't available.

 Foreigner.load_adapter! if ActiveRecord::Base.connection_pool
@mdi
Copy link

mdi commented Mar 2, 2011

I'm also seeing this issue with 0.9.1.

@matthuhiggins
Copy link
Owner

Are you guys only seeing this with the combo of Rails 2.X and Bundler? I've had a pain supporting both rails 2 and 3 at the same time, and maybe should have just created a Rails 2 branch for those who haven't upgraded.

@mczepiel
Copy link
Author

In my case it was Rails 2.x and Bundler. I'm actually not in that position anymore and the codebase eventually moved to Rails 3.x so I'm not able to do much more in the way of troubleshooting.

I'm pretty certain the reliance on the railtie after_intialize is the cause here.

@matthuhiggins
Copy link
Owner

I'm dropping support for Rails 2.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants