Open jamesst20 opened 2 weeks ago
Hi,
I noticed that no preloading happens if I have decorated records when using Draper gem.
Unfortunately it doesn't seem as simple as changing the condition here https://github.com/procore-oss/blueprinter-activerecord/blob/main/lib/blueprinter-activerecord/preloader.rb#L41 from
-if object.is_a?(ActiveRecord::Relation) && !object.loaded? +if (object.is_a?(ActiveRecord::Relation) || object.is_a?(ActiveRecord::Relation)) && !(object.try(:object) || object).loaded?
It still will not preload the records.
I tried preloading prior decorating as well without success:
records = records.preload_blueprint.decorate MyBlueprint.render_as_hash(records)
It would be great if this gem could be supported somehow. Thanks in advance
If you want to preload prior, you have include the blueprint (and view name, if it's not :default). The following should work:
:default
records = records .preload_blueprint(MyBlueprint, :view_name) .decorate
Hi,
I noticed that no preloading happens if I have decorated records when using Draper gem.
Unfortunately it doesn't seem as simple as changing the condition here https://github.com/procore-oss/blueprinter-activerecord/blob/main/lib/blueprinter-activerecord/preloader.rb#L41 from
It still will not preload the records.
I tried preloading prior decorating as well without success:
It would be great if this gem could be supported somehow. Thanks in advance