From 3422df002ead8c7c92d7267274a81fa9ad436b57 Mon Sep 17 00:00:00 2001 From: ymatsumoto Date: Sat, 4 May 2013 13:29:01 +0900 Subject: [PATCH] =?utf8?q?refs=20#1587=20=E3=83=AC=E3=82=B3=E3=83=A1?= =?utf8?q?=E3=83=B3=E3=83=89=E5=90=91=E3=81=91=E3=81=AETSV=E3=83=80?= =?utf8?q?=E3=82=A6=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E3=82=92=E3=81=A7?= =?utf8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- app/controllers/recommend_controller.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/controllers/recommend_controller.rb b/app/controllers/recommend_controller.rb index dad1745..e3b5047 100644 --- a/app/controllers/recommend_controller.rb +++ b/app/controllers/recommend_controller.rb @@ -2,8 +2,7 @@ class RecommendController < ApplicationController def tsv conditions = Product.default_condition @products = Product.find(:all, :conditions => flatten_conditions(conditions)) - f = StringIO.new('', 'w') - CSV::Writer.generate(f,"\t","\r\n") do | writer | + csv_data = CSV.generate("",:col_sep => "\t",:row_sep => "\r\n") do | writer | writer << [:item_code, :name, :url, :stock_flg, :comment, :category, :area, :price, :img_url] @products.each do | product | columns = [] @@ -20,8 +19,6 @@ class RecommendController < ApplicationController end end filename = "tsv.tsv" - headers['Content-Type'] = "application/octet-stream; name=#{filename}" - headers['Content-Disposition'] = "attachment; filename=#{filename}" - render :text => f.string + send_csv(csv_data,filename) end end -- 2.11.0