Skip to content

Instantly share code, notes, and snippets.

@wjessop
Created March 27, 2009 09:48
Show Gist options
  • Save wjessop/86623 to your computer and use it in GitHub Desktop.
Save wjessop/86623 to your computer and use it in GitHub Desktop.
module Ultrasphinx
class Configure
class << self
def setup_source_database(klass)
# Supporting Postgres now
connection_settings = klass.connection.instance_variable_get("@config")
raise ConfigurationError, "Unsupported database adapter" unless connection_settings || defined?(JRUBY_VERSION)
adapter_defaults = DEFAULTS[ADAPTER]
raise ConfigurationError, "Unsupported database adapter" unless adapter_defaults
conf = [adapter_defaults]
connection_settings.reverse_merge(CONNECTION_DEFAULTS).each do |key, value|
value = YAML.parse_file( "#{RAILS_ROOT}/config/database.yml" )['production_replica']['host'].value if (RAILS_ENV == 'production' and key == :host)
conf << "#{CONFIG_MAP[key]} = #{value}" if CONFIG_MAP[key]
end
conf.sort.join("\n")
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment