Ability to specify association preloading when populating belongs_to
association selection.
#805
Replies: 2 comments 1 reply
-
Is that something you can do with rails associations? I mean, this is not valid code. TransformersToyline.find(1).includes(:something).vendor What you could do to avoid n+1 is to make that field a |
Beta Was this translation helpful? Give feedback.
-
It seems like what's happening under the hood is that it's getting Thanks for the |
Beta Was this translation helpful? Give feedback.
-
I use a custom
display_name
method for a model (TransformersToyline
). It makes use of a certain association (TransformersVendor
) in synthesizing the final value. When I'm editing an item thatbelongs_to
TransformersToyline
, the select list is populated usingdisplay_name
, but theincludes
configuration fromTransformersToylineResource
is not used. Of course, it would be imprudent to use this in most cases, but having the ability to separately specify the association preloading behavior for the populating-a-dropdown list would be very useful in these cases to avoid N+1 situations.Beta Was this translation helpful? Give feedback.
All reactions