Is there a way to write a csv file using a hash instead of an array? Something like this:
header_keys = :first_name, :last_name, :email FasterCSV.open("path/to/file.csv", "w") do |csv| User.all.do |user| csv << user end end
Thanks...
Is there a way to write a csv file using a hash instead of an array? Something like this:
header_keys = :first_name, :last_name, :email FasterCSV.open("path/to/file.csv", "w") do |csv| User.all.do |user| csv << user end end
Thanks...
Is there a way to write a csv file using a hash instead of an array? Something like this:
header_keys = :first_name, :last_name, :email FasterCSV.open("path/to/file.csv", "w") do |csv| User.all.do |user| csv << user
csv << user.attributes.values_at(*header_keys)
end end
Thanks...
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Rob Biedenharn Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab@GaslightSoftware.com http://GaslightSoftware.com/