I have a csv file with about 30 columns that i would like to output, and would like these to appear in my .csv.erb on different lines, for example:
<%= quantity.line_number %>,
<%= quantity.created_at.strftime("%Y-%m-%d %H:%M:%S") %>,
<%= quantity.partner_entity_no %>,
<%= quantity.partner_name %>,
However when I execute this then my .csv file has line breaks after every ‘,’ I would like to 1) keep each column on separate line in source and 2) have non line breaks in the output .csv file. How could I make this happen?
Use the stdlib CSV class to get csv quoting and escaping semantics right. Or more conveniently, use its Array#to_csv helper method.