Commit 5c558e4
committed
Handle nil :uses through a polymorphic
When you `includes(:polymorphic => :attr)` and the `:attr` does not have a `:uses`,
this threw an exception.
Reason: Rails 7.2 added a `to_sym` in `reflect_on_association()`,
since `uses[:attr] = nil`, calling `reflect_on_association(nil)` had issues:
```
Failure/Error: reflection = record.class._reflect_on_association(association)
NoMethodError:
undefined method `to_sym' for nil
# /Users/kbrock/.gem/ruby/3.3.5/gems/activerecord-7.2.2.1/lib/active_record/reflection.rb:127:in `_reflect_on_association'
# ./lib/active_record/virtual_attributes/virtual_fields.rb:189:in `block in grouped_records'
```
refs:
- rails/rails#5172
- ManageIQ/manageiq-api#1284
Fixes: ManageIQ/manageiq#235181 parent d6a3c90 commit 5c558e4
File tree
3 files changed
+14
-0
lines changed- lib/active_record/virtual_attributes
- spec
- db
3 files changed
+14
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
186 | 187 | | |
187 | 188 | | |
188 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
118 | 124 | | |
119 | 125 | | |
120 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
109 | 116 | | |
110 | 117 | | |
111 | 118 | | |
| |||
0 commit comments