Exporting as CSV file in RAILS.
I have used Fastercsv gem to generate csv data and used send_data method.. def create_csv @customers = Customer.all csv_string = FasterCSV.generate do |csv| csv @customers.each do |customer| csv end end send_data csv_string, :filename => "customers.csv" , :type=>"text/csv" end