12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/comma/render_as_csv.rb', line 12
def render_with_csv(options = nil, = {}, &block)
return render_without_csv(options, , &block) unless options.is_a?(Hash) and options[:csv].present?
content = options.delete(:csv)
style = options.delete(:style) || :default
filename = options.delete(:filename)
.merge!(
'Content-Transfer-Encoding' => 'binary',
'Content-Type' => 'text/csv; charset=utf-8'
)
= "attachment"
+= "; filename=\"#{filename}\"" if filename.present?
.merge!('Content-Disposition' => )
@performed_render = false
render_stream :status => 200,
:content => Array(content),
:style => style
end
|