Possibly improve using different database connections

This commit is contained in:
Jon Atack 2014-11-07 20:46:17 +01:00
parent 495f9b0c2e
commit f858dd6d98
1 changed files with 7 additions and 6 deletions

View File

@ -22,12 +22,13 @@ module Ransack
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 = @engine.connection.schema_cache
raise "No table named #{table} exists" unless schema_cache.table_exists?(table)
schema_cache.columns_hash(table)[name].type
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
connection.schema_cache.columns_hash(table)[name].type
end
def evaluate(search, opts = {})