I have a model Company, this model has a field Address.
Company.first.address
returns the following in the console:
"11 Local Street,\r\n" + "City,\r\n" + "POSTCODE"
This throws a spanner in the works when I try to export using
CSV.generate_line([company.name, company.address])
The address field spans more than one column and therefore makes the CSV not useful.
Can't seem to find a way to turn it into a single quoted string.
This is the full create.csv.erb:
<%- headers = [
'name',
'email',
'address',
'phone',
'contract_date',
'deal_percentage',
'active',
'editable'
] -%>
<%= (CSV.generate_line(headers)).strip %>
<% @companies.each do |company| %>
<%= CSV.generate_line([
company.name,
company.email,
company.address,
company.phone,
company.contract_date,
company.deal_percentage,
company.active,
company.editable
], { quote_char: "\0", encoding: "UTF-8" }).strip %>
<% end %>
I'm using Ruby 2.4.0 and Rails 5.0.1.