Skip to content

Instantly share code, notes, and snippets.

View stefanluptak's full-sized avatar

Stefan Luptak stefanluptak

View GitHub Profile
module UseMultiDB
def use_db(db_name, options={})
begin
establish_connection "#{db_name}_#{RAILS_ENV}"
set_table_name options[:table_name] unless options[:table_name].blank?
self.inheritance_column = '_sti_type_disabled' unless options[:sti]
rescue
Rails.logger.info "ERROR unable to establish connection to database '#{db_name}_#{RAILS_ENV}'"
end
end