Can i dynamically select options for export?
MaksimAbramchuk opened this issue · 1 comments
MaksimAbramchuk commented
For example I have model Order
class Order < ActiveRecord::Base
belongs_to :organization
comma do
id
state
organization :name
organization :id
end
end
Can i pass any options to csv renderer like {:state, organization: [:id]}
to export only this fields?
eitoball commented
No, you cannot. You might want to try to use __use___
keyword.
For example, you could define your model like:
class Order < ActiveRecord::Base
belongs_to :organization
comma do
__use__ :base
id
organization :name
end
comma :base do
state
organization :id
end
end
Then, Order.where(state: 'done').to_comma(style: :brief)
to export only {:state, organization: [:id]}
, and to_comma
to export all fields.