diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-07-10 11:42:51 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-07-10 11:42:51 +0900 |
commit | b7d229d1fabbd271fd37e9f4eac316a44d690842 (patch) | |
tree | b11b93c8db6c06ff17be9fd3c93c1bbd4369cc32 /activerecord/lib | |
parent | 777ff90ab5da3a7cf8522231270b50c4b29fb15f (diff) | |
download | rails-b7d229d1fabbd271fd37e9f4eac316a44d690842.tar.gz rails-b7d229d1fabbd271fd37e9f4eac316a44d690842.tar.bz2 rails-b7d229d1fabbd271fd37e9f4eac316a44d690842.zip |
Correctly return `associated_table` when `associated_with?` is true
`AssociationQueryHandler` requires `association` initialized
`TableMetadata` even if `table_name == arel_table.name`.
Fixes #25689.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/table_metadata.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/table_metadata.rb b/activerecord/lib/active_record/table_metadata.rb index a1326aa359..5fe0d8b5e4 100644 --- a/activerecord/lib/active_record/table_metadata.rb +++ b/activerecord/lib/active_record/table_metadata.rb @@ -42,11 +42,11 @@ module ActiveRecord end def associated_table(table_name) - return self if table_name == arel_table.name - association = klass._reflect_on_association(table_name) || klass._reflect_on_association(table_name.singularize) - if association && !association.polymorphic? + if !association && table_name == arel_table.name + return self + elsif association && !association.polymorphic? association_klass = association.klass arel_table = association_klass.arel_table.alias(table_name) else |