Sha256: 0f37dccc1c55022064e189ad2c1b95129546e3abcd4c9e3b8c57483b51bc9361
Contents?: true
Size: 590 Bytes
Versions: 10
Compression:
Stored size: 590 Bytes
Contents
if defined? ActionController ['csv','ods','xlsx'].each do |format| ActionController::Renderers.add(format.to_sym) do |data, options| if defined?(ActiveRecord) && data.is_a?(ActiveRecord::Relation) options[:filename] ||= data.klass.name.pluralize data = data.send("to_#{format}") end options[:filename] = options[:filename] ? options[:filename].strip.sub(/\.#{format}$/i,'') : 'data' options[:filename] += ".#{format}" send_data data, type: format.to_sym, disposition: :attachment, filename: options[:filename] end end end
Version data entries
10 entries across 10 versions & 1 rubygems