In a Rails application, an administrator can export user data in csv format. Each user of my application has a photo of his profile .... my client wants to include a user photo in a CSV file. I do not know how to do that. can someone please help me ....
I am using quickcsv gem and here is some kind of my controller code for reference
In my controller:
require 'fastercsv' def getcsv entries = User.find(:all) csv_string = FasterCSV.generate do |csv| csv << ["first_name","last_name","username","address","photo" ] entries.each do |e| csv << [e.first_name,e.last_name,e.username,e.address,e.photo.url] end end send_data csv_string,:type=>'text/csv;charset=iso-8859-1; header=present', :filename=>"entries.csv",:disposition => 'attachment' end
source share