Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

generate csv file rails

def csv_cars
  headers = ['column one', 'column two', 'column three']

  csv_data = CSV.generate(headers: true) do |csv|
    csv << headers
    csv << ["A", "B", "C"]
  end

  send_data csv_data, filename: "data-#{Date.today.to_s}.csv", disposition: :attachment
end
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #generate #csv #file #rails
ADD COMMENT
Topic
Name
6+3 =