aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/public_body_controller.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-09-20 15:06:32 +0100
committerLouise Crow <louise.crow@gmail.com>2012-09-20 15:06:32 +0100
commitadd084ee6047d3cae72e3e445135b122d8ba2cc8 (patch)
treef9763b73753c44562d6572035ab71b4bae2957a0 /app/controllers/public_body_controller.rb
parent69103f5e83d538cd3aa9a3ea39cc5736aaec21e8 (diff)
parentaebcdc082f277b3569d1300ebeda43c503d8aec5 (diff)
Merge branch 'release/0.6.6'0.6.6
Conflicts: locale/cs/app.po locale/es/app.po
Diffstat (limited to 'app/controllers/public_body_controller.rb')
-rw-r--r--app/controllers/public_body_controller.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 95d936e54..b8ea82a66 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -7,7 +7,7 @@
#
# $Id: public_body_controller.rb,v 1.8 2009-09-14 13:27:00 francis Exp $
-require 'csv'
+require 'fastercsv'
class PublicBodyController < ApplicationController
# XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL
@@ -148,10 +148,10 @@ class PublicBodyController < ApplicationController
end
def list_all_csv
- public_bodies = PublicBody.find(:all, :order => 'url_name')
- report = StringIO.new
- CSV::Writer.generate(report, ',') do |title|
- title << [
+ public_bodies = PublicBody.find(:all, :order => 'url_name',
+ :include => [:translations, :tags])
+ report = FasterCSV.generate() do |csv|
+ csv << [
'Name',
'Short name',
# deliberately not including 'Request email'
@@ -164,7 +164,7 @@ class PublicBodyController < ApplicationController
'Version',
]
public_bodies.each do |public_body|
- title << [
+ csv << [
public_body.name,
public_body.short_name,
# DO NOT include request_email (we don't want to make it
@@ -179,8 +179,7 @@ class PublicBodyController < ApplicationController
]
end
end
- report.rewind
- send_data(report.read, :type=> 'text/csv; charset=utf-8; header=present',
+ send_data(report, :type=> 'text/csv; charset=utf-8; header=present',
:filename => 'all-authorities.csv',
:disposition =>'attachment', :encoding => 'utf8')
end