-
Notifications
You must be signed in to change notification settings - Fork 232
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
uninitialized constant ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig #201
Comments
when I change the database.yml file to just use the postgres adapter -> no crash.. |
What does the pushr code that loads this look like? Is it calling |
this is the complete script for the pushr daemon.. the last line crashes
|
@teeparham any chance to get this fixed soon? This is blocking our project. |
@teeparham do you have a suggestion on how to circumvent this error? |
@teeparham Hi Tee, did you have a chance to look at this? |
@teeparham Also running into this issue, it looks like a bug with activerecord-postgis-adapter. Any possible resolution in sight here? |
The problem:When we use postgresql_adapter.rb override the original activerecord-postgis-adapter databases.rake call the method ActiveRecord::Base.configurations
.values_at(*environments)... ActiveRecord::Base.configurations at active_record/core.rb: def self.configurations=(config)
@@configurations = ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig.new(config).resolve
end But, we don't have A very ugly "solution":In your rails application, create the file module ActiveRecord
module ConnectionHandling # :nodoc:
RAILS_ENV = -> { (Rails.env if defined?(Rails.env)) || ENV["RAILS_ENV"] || ENV["RACK_ENV"] }
DEFAULT_ENV = -> { RAILS_ENV.call || "default_env" }
class MergeAndResolveDefaultUrlConfig # :nodoc:
def initialize(raw_configurations)
@raw_config = raw_configurations.dup
@env = DEFAULT_ENV.call.to_s
end
# Returns fully resolved connection hashes.
# Merges connection information from `ENV['DATABASE_URL']` if available.
def resolve
ConnectionAdapters::ConnectionSpecification::Resolver.new(config).resolve_all
end
private
def config
@raw_config.dup.tap do |cfg|
if url = ENV['DATABASE_URL']
cfg[@env] ||= {}
cfg[@env]["url"] ||= url
end
end
end
end
end
end And require the initializer in require 'rails/all'
# Bad, ugly, horrible solution:
require './config/initializers/postgis_hotfix'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end Real solution:
Maybe it's an ActiveRecord issue... The
If |
thank you for the pointers, @gbaptista ! Will try it out this week |
this did not work for us - we got an error from another Gem (attr_encrypted) -- looks like a problem in the order of how the railties are executed /...../.rvm/gems/ruby-2.2.3/gems/attr_encrypted-1.3.4/lib/attr_encrypted.rb:259:in |
what is a cleaner way to ensure that ActiveRecord::ConnectionHandling is loaded before ./lib/active_record/connection_adapters/postgis/create_connection.rb ? |
Any update on this? |
The If that's not possible, pull requests are welcome to fix this issue and can be merged into an older branch, but it is unlikely that this issue will be fixed by any current maintainers. We will try to maintain all currently supported versions of rails, and and while rails 5 is still supported, it seems like this error is occuring only when using gems or executing tasks that change the default order of |
Rails startup crashes when starting daemon through
bundle exec
ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig is not defined
Rails 4.2.4
pg (0.18.4)
happens with activerecord-postgis-adapter 3.0.0 and 3.1.0
The text was updated successfully, but these errors were encountered: