7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rendered_csv/controller.rb', line 7
def render_csv(filename = nil, template = nil)
filename ||= params[:action]
filename += '.csv'
if request.env['HTTP_USER_AGENT'] =~ /msie/i
['Pragma'] = 'public'
["Content-Type"] = "text/plain"
['Cache-Control'] = 'no-cache, must-revalidate, post-check=0, pre-check=0'
['Content-Disposition'] = "attachment; filename=\"#{filename}\""
['Expires'] = "0"
else
["Content-Type"] ||= 'text/csv'
["Content-Disposition"] = "attachment; filename=\"#{filename}\""
end
if template.nil?
render :layout => false
else
render template, :layout => false
end
end
|