Skip to content

Instantly share code, notes, and snippets.

@schneems
Last active December 14, 2015 17:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save schneems/5119875 to your computer and use it in GitHub Desktop.
Save schneems/5119875 to your computer and use it in GitHub Desktop.
# Set the number of connections AR pool
#
# place in an initializer such as: config/connection_pool.rb
Rails.application.config.after_initialize do
ActiveRecord::Base.connection_pool.disconnect!
ActiveSupport.on_load(:active_record) do
config = Rails.application.config.database_configuration[Rails.env]
config['pool'] = ENV['DB_POOL'] || 6
ActiveRecord::Base.establish_connection(config)
end
end
@hgmnz
Copy link

hgmnz commented Mar 8, 2013

place in config/connection_pool.rb

not in config/initializers/whatevs?

@schneems
Copy link
Author

schneems commented Mar 8, 2013

@hgmnz any initializer should work, unless you're doing something screwy like this in another initializer and order might matter.

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