require 'activesupport' if defined?(ActionController) ActionController::Base.class_eval do def render_with_csv(options = nil, extra_options = {}, &block) return render_without_csv(options, extra_options, &block) unless (options.respond_to? '[]') and options[:csv] data = options.delete(:csv) send_data Array(data).to_csv, options.merge(:type => :csv) end alias_method_chain :render, :csv end end