Sha256: 49203623f5ec63bf49074266b5fd890b8aa7cf36650fb9ecfc637d22d691c45a

Contents?: true

Size: 907 Bytes

Versions: 6

Compression:

Stored size: 907 Bytes

Contents

module Effective
  class DatatablesController < ApplicationController
    skip_log_page_views if defined?(EffectiveLogging)

    # This will respond to both a GET and a POST
    def show
      @datatable = Effective::Datatable.find(params[:id], params[:attributes])
      @datatable.view = view_context if !@datatable.nil?

      EffectiveDatatables.authorized?(self, :index, @datatable.try(:collection_class) || Effective::Datatable)

      respond_to do |format|
        format.html
        format.json {
          if Rails.env.production?
            render :json => (@datatable.to_json rescue error_json)
          else
            render :json => @datatable.to_json
          end
        }
      end

    end

    private

    def error_json
      {
        :draw => params[:draw].to_i,
        :data => [],
        :recordsTotal => 0,
        :recordsFiltered => 0,
      }.to_json
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
effective_datatables-1.8.3 app/controllers/effective/datatables_controller.rb
effective_datatables-1.8.2 app/controllers/effective/datatables_controller.rb
effective_datatables-1.8.1 app/controllers/effective/datatables_controller.rb
effective_datatables-1.8.0 app/controllers/effective/datatables_controller.rb
effective_datatables-1.7.1 app/controllers/effective/datatables_controller.rb
effective_datatables-1.7.0 app/controllers/effective/datatables_controller.rb