Skip to content

Commit

Permalink
Pull out the first key as the association - sketchy
Browse files Browse the repository at this point in the history
  • Loading branch information
jrafanie committed Jun 21, 2024
1 parent 2ed7523 commit 9a2a503
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/active_record/virtual_attributes/virtual_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ def grouped_records
# 1 line optimization for single element array:
@association = association.first if association.kind_of?(Array)# && association.size == 1

# !!!!
@association = association.keys.first if association.kind_of?(Hash)

case association
when Symbol, String
reflection = record.class._reflect_on_association(association)
Expand Down

0 comments on commit 9a2a503

Please sign in to comment.