module DataTables::ActiveModelSerializers

Constants

HEADERS
MEDIA_TYPE

Public Class Methods

install() click to toggle source
# File lib/data_tables/active_model_serializers/register_dt_renderer.rb, line 21
def self.install
  # actionpack/lib/action_dispatch/http/mime_types.rb
  Mime::Type.register_alias MEDIA_TYPE, :dt, %w( text/plain text/x-json application/jsonrequest application/dt application/datatable )

  # if Rails::VERSION::MAJOR >= 5
  #   ActionDispatch::Request.parameter_parsers[:dt] = parser
  # else
  #   ActionDispatch::ParamsParser::DEFAULT_PARSERS[Mime[:dt]] = parser
  # end

  ::ActionController::Renderers.add :dt do |json, options|
    json = serialize_dt(json, options).to_json(options) unless json.is_a?(String)
    self.content_type ||= Mime[:dt]
    self.response_body = json
  end
end