Sha256: 2420d2017657f378f7feae8de7d38af58d440edaa8e168e2e8c1298aeee8e548

Contents?: true

Size: 858 Bytes

Versions: 6

Compression:

Stored size: 858 Bytes

Contents

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

    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.6.3 app/controllers/effective/datatables_controller.rb
effective_datatables-1.6.2 app/controllers/effective/datatables_controller.rb
effective_datatables-1.6.1 app/controllers/effective/datatables_controller.rb
effective_datatables-1.6.0 app/controllers/effective/datatables_controller.rb
effective_datatables-1.5.1 app/controllers/effective/datatables_controller.rb
effective_datatables-1.5.0 app/controllers/effective/datatables_controller.rb