Module: ActiveAdmin::SortableTable

Defined in:
lib/active_admin/sortable_table.rb,
lib/active_admin/sortable_table/engine.rb,
lib/active_admin/sortable_table/version.rb,
lib/active_admin/sortable_table/handle_column.rb

Overview

Include this module to registered page to enable ActiveAdmin Sortable Table extension end

Examples:


ActiveAdmin.register Category do
  include ActiveAdmin::SortableTable
  config.sort_order = 'position_asc'
  permit_params :position

  index do
    handle_column
    id_column
  end

Defined Under Namespace

Modules: HandleColumn Classes: Engine

Constant Summary collapse

VERSION =
'1.3.0'

Class Method Summary collapse

Class Method Details

.included(dsl) ⇒ void

This method returns an undefined value.

Parameters:

  • dsl (ActiveAdmin::DSL)


28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_admin/sortable_table.rb', line 28

def included(dsl) # rubocop:disable Metrics/AbcSize
  dsl.instance_eval do
    member_action :sort, method: :post do
      resource.insert_at params[:position].to_i
      head 200
    end

    member_action :move_to_top, method: :post do
      resource.move_to_top
      redirect_to request.headers['HTTP_REFERER'] || collection_path
    end
  end
end