I have a rails app with some nested data that I'd like to export as a CSV file
The models look like:
class ContainerRecord < ActiveRecord::Base
has_many :child_records
and
class ChildRecord < ActiveRecord::Base
belongs_to :container_record
I'd like to be able to export a CSV file with each ContainerRecord on a row with its information in the first few columns and a value from each ChildRecord in the remaining columns.
I can't guarantee the number of ChildRecords associated with each ContainerRecord and I don't care if I have a different number of non-null columns for each row.
I've attempted to use FasterCSV, but I get all of the data for the child records shoved into one column rather than a column for each.
Is this something that I can do with FasterCSV? If not, what method can I use to accomplish my goal?