Skip to content

Commit

Permalink
Fix CSV rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Calyhre committed May 15, 2017
1 parent 47493ca commit f7cd06f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
16 changes: 3 additions & 13 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion config/initializers/mime_types.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f7cd06f

Please sign in to comment.