Sha256: 78b41db75fd4f582c7fb096ad2c98a92400bf332b89f8d3e5d99e8090bc11fbe

Contents?: true

Size: 595 Bytes

Versions: 16

Compression:

Stored size: 595 Bytes

Contents

# For further explanation, check out RFC 2183
# https://www.ietf.org/rfc/rfc2183.txt
ActionController.add_renderer :csv do |obj, options|
  filename = options.fetch(:filename, 'data')

  disposition_type = options[:inline] || filename == 'inline' ? 'inline' : 'attachment'
  disposition_params = [disposition_type]
  if filename != 'inline'
    filename = "#{filename}.csv" unless filename =~ /\.csv$/
    disposition_params << "filename=#{filename}"
  end

  str = obj.respond_to?(:to_csv) ? obj.to_csv : obj.to_s
  send_data str, type: Mime::CSV, disposition: disposition_params.join(';')
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aleph_analytics-0.4.9.pre.dev config/initializers/action_controller_renderers.rb
aleph_analytics-0.4.8 config/initializers/action_controller_renderers.rb
aleph_analytics-0.4.7 config/initializers/action_controller_renderers.rb
aleph_analytics-0.4.4 config/initializers/action_controller_renderers.rb
aleph_analytics-0.4.2 config/initializers/action_controller_renderers.rb
aleph_analytics-0.4.1 config/initializers/action_controller_renderers.rb
aleph_analytics-0.3.0 config/initializers/action_controller_renderers.rb
aleph_analytics-0.2.0 config/initializers/action_controller_renderers.rb
aleph_analytics-0.1.0 config/initializers/action_controller_renderers.rb
aleph_analytics-0.0.6 config/initializers/action_controller_renderers.rb
aleph_analytics-0.0.5 config/initializers/action_controller_renderers.rb
aleph_analytics-0.0.4 config/initializers/action_controller_renderers.rb
aleph_analytics-0.0.3 config/initializers/action_controller_renderers.rb
aleph_analytics-0.0.2 config/initializers/action_controller_renderers.rb
aleph_analytics-0.0.1.alpha config/initializers/action_controller_renderers.rb
aleph_analytics-0.0.0.alpha config/initializers/action_controller_renderers.rb