lib/decisive/template_handler.rb in decisive-0.4.1 vs lib/decisive/template_handler.rb in decisive-0.4.2
- old
+ new
@@ -18,13 +18,13 @@
response.headers["Content-Disposition"] = %(attachment; filename="\#{context.filename}")
if controller.respond_to?(:new_controller_thread) # has AC::Live mixed in
begin
context.each do |row|
- response.stream.write row.to_csv
+ response.stream.write row.to_csv(force_quotes: true)
end
- raise if ENV["RAILS_ENV"] == "test" # WTF WTF without this the stream isn't closed in test mode??? WTF WTF
+ raise if Rails.env.test? # WTF WTF without this the stream isn't closed in test mode??? WTF WTF
ensure
response.stream.close
end
""
else
@@ -89,11 +89,13 @@
columns.map(&:label)
end
end
class RenderContext < Struct.new(:records, :filename, :block)
- def to_csv
- (header + body).map(&:to_csv).join
+ def to_csv(*args, **kwargs)
+ (header + body).map do |row|
+ row.to_csv(*args, **kwargs)
+ end.join
end
private
def header