I am attempting to generate a CSV file. Everything is fine except for blank fields, I'm not quite sure have ""
instead of actual quotes. I've provided the code I'm using to generate the file and some output.
<% headers = ["Username", "Name", "E-mail", "Phone Number"] %>
<%= CSV.generate_line headers %>
<% @users_before_paginate.each do |user| %>
<% row = [ "#{user.username}".html_safe ] %>
<% row << "#{user.profile.first_name} #{user.profile.last_name}".html_safe unless user.profile.blank? %>
<% row << "#{user.email}".html_safe unless user.profile.nil? %>
<% row << "#{user.profile.phone}".html_safe unless user.profile.nil? %>
<%= CSV.generate_line row %>
<% end %>
Output
Username,Name,E-mail,Phone Number
admin,LocalShopper ,[email protected],""
Brian,Oliveri Design ,[email protected],727-537-9617
LocalShopperJenn,Jennifer M Gentile ,[email protected],""