draper icon indicating copy to clipboard operation
draper copied to clipboard

Consider implement #preload in Draper::CollectionDecorator

Open teohm opened this issue 7 years ago • 2 comments

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?

teohm avatar Jun 22 '17 08:06 teohm

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.

codebycliff avatar Jul 18 '17 13:07 codebycliff