Skip to content

Commit

Permalink
TableMetadata#associated_table look for reflections by table_name
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewn617 committed Mar 25, 2024
1 parent 61a3e61 commit 7bcaa77
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/table_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def associated_with?(table_name)
end

def associated_table(table_name)
reflection = klass._reflect_on_association(table_name) || klass._reflect_on_association(table_name.singularize)
reflection = klass._reflect_on_association(table_name) || klass._reflect_on_association(table_name.singularize) || klass.reflections.values.detect { |reflection| reflection.table_name == table_name }

if !reflection && table_name == arel_table.name
return self
Expand Down

0 comments on commit 7bcaa77

Please sign in to comment.