draper
draper copied to clipboard
Consider implement #preload in Draper::CollectionDecorator
We're using datagrid gem together with draper decorators.
They works very well so far, until recently datagrid introduces preload feature, where it actively preloads associations when rendering a ActiveRecord resource.
To fix this breaking change, we have to implement #preload
in our Draper::CollectionDecorator
subclasses:
class MyCollectionDecorator < Draper::CollectionDecorator
def preload(*args)
object.preload(*args).decorate
end
end
I wonder if it makes sense to move this #preload
implementation into Draper::CollectionDecorator
?
What do you all think?
Thanks for the suggestion!
I've seen a few issues related to this functionality. Let me look into those and get back to you. At first glance I don't see a problem with adding this functionality, but I'll want to get a little more context before I give you a full answer.