autotelik / datashift

Full Excel/CSV Import/Export facilities for Rails
http://www.autotelik.co.uk
Other
136 stars 75 forks source link

Create has_many records on import #32

Closed GeekOnCoffee closed 8 years ago

GeekOnCoffee commented 9 years ago

Is it possible to create a has_many record on import? Do i have to create a custom loader (like the Spree Product loader)?

autotelik commented 9 years ago

It should work for simple cases, where the association already exists in the DB, it can find the association based on a key and populate the loading model. See the examples, such as spec/fixtures/ProjectsSingleCategories.xls .. the loading Project can be populated with many Categories, being looked up by their reference.

In the Spree loader, we are not just finding associations but building them on the fly. I have started work on implementing support for a full definition of an association, within the column, in e.g json, enabling them to be built more generically and dynamically. this will form part of the major overhaul underway in the split_into_concerns branch

autotelik commented 9 years ago

p.s the export of association in json, to a column should be in master already. See the column packer file