diff --git a/lib/ransack/adapters/active_record/context.rb b/lib/ransack/adapters/active_record/context.rb index c21580615..dc1742973 100644 --- a/lib/ransack/adapters/active_record/context.rb +++ b/lib/ransack/adapters/active_record/context.rb @@ -25,7 +25,7 @@ def type_for(attr) name = attr.arel_attribute.name.to_s table = attr.arel_attribute.relation.table_name schema_cache = @engine.connection.schema_cache - unless schema_cache.table_exists?(table) + unless schema_cache.send(database_table_exists?, table) raise "No table named #{table} exists." end schema_cache.columns_hash(table)[name].type @@ -134,6 +134,14 @@ def alias_tracker private + def database_table_exists? + if ::ActiveRecord::VERSION::MAJOR >= 5 + :data_source_exists? + else + :table_exists? + end + end + def get_parent_and_attribute_name(str, parent = @base) attr_name = nil