diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d305b27c..6aae72a1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,7 @@ jobs: fail-fast: false matrix: rails: + - v7.1.0 - v7.0.3 - v6.1.6 ruby: @@ -38,6 +39,7 @@ jobs: fail-fast: false matrix: rails: + - v7.1.0 - v7.0.3 - v6.1.6 ruby: @@ -72,6 +74,7 @@ jobs: fail-fast: false matrix: rails: + - v7.1.0 - v7.0.3 - v6.1.6 ruby: diff --git a/lib/ransack/adapters/active_record/context.rb b/lib/ransack/adapters/active_record/context.rb index e0f0c652..48a6ea80 100644 --- a/lib/ransack/adapters/active_record/context.rb +++ b/lib/ransack/adapters/active_record/context.rb @@ -12,8 +12,9 @@ def relation_for(object) def type_for(attr) return nil unless attr && attr.valid? + relation = attr.arel_attribute.relation name = attr.arel_attribute.name.to_s - table = attr.arel_attribute.relation.table_name + table = relation.respond_to?(:table_name) ? relation.table_name : relation.name schema_cache = self.klass.connection.schema_cache unless schema_cache.send(:data_source_exists?, table) raise "No table named #{table} exists."