Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 801 Bytes

ordering.md

File metadata and controls

39 lines (29 loc) · 801 Bytes

Model Ordering

Slickr uses ActsAsList for ordering. In order to use it in you app you must first add a position column to the required table like in the example below:

rails g migration AddPositionToAdminUser position:integer
rake db:migrate

Then add acts_as_list to your model (and also a default scope if you need it):

class AdminUser < ActiveRecord::Base
  acts_as_list
  default_scope { order(position: :asc) }
end

In your Active Admin model you then need to add the following:

ActiveAdmin.register AdminUser do
  config.sort_order = 'position_asc'
  config.paginate   = false
  reorderable

  ...

  index as: :reorderable_table do
    ...
  end

  ...
end

That's it, you now have reorderable tables.