comma-csv / comma

Comma is a small CSV (ie. comma separated values) generation extension for Ruby objects, that lets you seamlessly define a CSV output format via a small DSL

Home Page:https://github.com/comma-csv/comma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

has_many through output

anlek opened this issue · comments

I'm trying to output something like this:
user have many custom_values
custom_values belong to custom fields
I want to export in a csv all the custom_values for all the custom_fields

Something like
class User < ActiveRecord::Base
has_many :custom_values
belongs_to :account
comma do
name
account.custom_fields.each do |cf|
custom_value :for => {:custom_field_id => cf.id}, :name => cf.name
end
end
end

Any ideas on how I can achieve this?