Skip to content

Eager loading and preload! method #1

@bobmaerten

Description

@bobmaerten

Hi!

First of all thank you for providing a fresh approach to exporting data. It's just the kind of thing I was looking for. Though very young, this gem has found a place in our controllers and rake tasks dedicated to output data from our DB.

Still... youngness, while sometimes good for freshness, is also sometimes a pain for documentation and comprehension of intents. I had trouble sorting out the necessity of overriding the object_class method, to let specifying whatever-we-wanted-for-export-class-name.

And now I have another bad time with eager-loading. I want to export customers data with a lot of nested classes, so I naively pass a eager-loaded scope to my exporter:

scope = Customer.where(id: customer_ids).includes(:addresses, :orders => :order_items)
MyCustomerExport.new(scope).to_xlsx.read

but it does not seems to works by looking at my dev logs.

I also noticed an empty preload! method in the export.rb but I don't really know what to do more for the objects to use eager loading when exporter parses the objects. Any tips on that?

Sorry for not being very clear (not english native). I tried to figure out how Xport::Export class works, but it seems to be much more meta than I can't take! ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions