From f7cd06f8dfe74c43e75e70230d6f66bba8da2e0a Mon Sep 17 00:00:00 2001 From: Charley DAVID Date: Mon, 15 May 2017 14:30:36 -0300 Subject: [PATCH] Fix CSV rendering --- app/controllers/application_controller.rb | 16 +++------------- config/initializers/mime_types.rb | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 62735bd..929b0da 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,10 +1,6 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception - before_action do - request.format = :csv - end - def prices games = Game.all.includes(:prices).sort_by(&:title).group_by(&:parsed_game_code) countries = Price.pluck(:country).uniq.sort @@ -26,9 +22,7 @@ def prices end end - respond_to do |format| - format.csv { send_data csv } - end + send_data csv, type: 'text/csv; charset=utf-8; header=present' end def rates @@ -46,9 +40,7 @@ def rates end end - respond_to do |format| - format.csv { send_data csv } - end + send_data csv, type: 'text/csv; charset=utf-8; header=present' end def glossary @@ -75,8 +67,6 @@ def glossary end - respond_to do |format| - format.csv { send_data csv } - end + send_data csv, type: 'text/csv; charset=utf-8; header=present' end end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index dc18996..68dd414 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,4 +1,4 @@ # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf +Mime::Type.register 'text/csv', :csv