Skip to content

Instantly share code, notes, and snippets.

@samflores
Last active August 3, 2017 15:56
Show Gist options
  • Save samflores/023640e518ee16fa47dce2fc564b06cf to your computer and use it in GitHub Desktop.
Save samflores/023640e518ee16fa47dce2fc564b06cf to your computer and use it in GitHub Desktop.
# app/admin/picture.rb
ActiveAdmin.register Picture, namespace: :sales do
config.filters = false
config.clear_action_items!
config.clear_batch_actions!
actions :index, :show, :edit, :update
sidebar I18n.t('active_admin.sidebars.search'), only: :index do
# define sidebar here
end
index as: :grid, columns: 4 do |picture|
# define index here
end
show do
# define show here
end
controller do
def scoped_collection
collection = end_of_association_chain
collection = collection.for_projects_containing(params[:s]) unless params[:s].blank?
collection.recent.ranked # <== apply your sorting here
end
def apply_sorting(chain)
chain # <== return the relation without ActiveAdmin's default sorting
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment