From fcba7e9f3a613329d29ffd7fbb53737cf0db3d06 Mon Sep 17 00:00:00 2001 From: Nathan Appere Date: Mon, 12 Feb 2018 14:41:04 -0800 Subject: [PATCH] Revert a change made in 2014 that prevent Ransack from finding the correct DB --- lib/ransack/adapters/active_record/context.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ransack/adapters/active_record/context.rb b/lib/ransack/adapters/active_record/context.rb index ed1778d5b..7065bf2f1 100644 --- a/lib/ransack/adapters/active_record/context.rb +++ b/lib/ransack/adapters/active_record/context.rb @@ -25,13 +25,13 @@ def relation_for(object) def type_for(attr) return nil unless attr && attr.valid? - name = attr.arel_attribute.name.to_s - table = attr.arel_attribute.relation.table_name - schema_cache = ::ActiveRecord::Base.connection.schema_cache - unless schema_cache.send(database_table_exists?, table) - raise "No table named #{table} exists." + name = attr.arel_attribute.name.to_s + table = attr.arel_attribute.relation.table_name + connection = attr.klass.connection + unless connection.table_exists?(table) + raise "No table named #{table} exists" end - schema_cache.columns_hash(table)[name].type + connection.schema_cache.columns_hash(table)[name].type end def evaluate(search, opts = {})