Possibly improve using different database connections
This commit is contained in:
parent
495f9b0c2e
commit
f858dd6d98
|
@ -22,12 +22,13 @@ module Ransack
|
||||||
|
|
||||||
def type_for(attr)
|
def type_for(attr)
|
||||||
return nil unless attr && attr.valid?
|
return nil unless attr && attr.valid?
|
||||||
name = attr.arel_attribute.name.to_s
|
name = attr.arel_attribute.name.to_s
|
||||||
table = attr.arel_attribute.relation.table_name
|
table = attr.arel_attribute.relation.table_name
|
||||||
|
connection = attr.klass.connection
|
||||||
schema_cache = @engine.connection.schema_cache
|
unless connection.table_exists?(table)
|
||||||
raise "No table named #{table} exists" unless schema_cache.table_exists?(table)
|
raise "No table named #{table} exists"
|
||||||
schema_cache.columns_hash(table)[name].type
|
end
|
||||||
|
connection.schema_cache.columns_hash(table)[name].type
|
||||||
end
|
end
|
||||||
|
|
||||||
def evaluate(search, opts = {})
|
def evaluate(search, opts = {})
|
||||||
|
|
Loading…
Reference in New Issue