I am working on to allow download an excel file with the below code:
login = Etc.getlogin
@dataFile = "C:/rails/#{login}data.csv"
csv1=CSV.open(@dataFile, 'w') do |csv|
$data.each do |eachrow|
csv << [eachrow.name+"@gmail.com"]
end
end
send_file(@dataFile, :filename => "#{login}data", :type => "application/csv")
Using the above code, I am able to create a file and write the data.
Instead of this, how do i write the data in csv and get downloaded into users machine instead of saving in local/server.