comma-csv/comma

Getting values for has_many

Opened this issue · 3 comments

Hi,

I have a Person class that has many Cars and l want to show the Car number plates for a person how do l do this all l can seem to do is get the size

Sentia,

Could you describe the desired output? Is it something like this:

person_id, number_plate
1, AAA
1, CAB
2, DDD

Then you should specify the comma block in the Car model and not in the Person class. let me know.

What l need to be able to do is export all people and have a column in the export that contains all there number plates as well for example
name plates
tom smith BGS-GSH
asd-adsa

In that case create a virtual attribute on Person like
def number_plates_string
number_plates.map {|plate| plate.number}.join " "
end

and then use this attribute in the comma block.

Best regards,

Pieter