In a resource registered with ActiveAdmin, I have the following default_scope defined for the model:
default_scope :order => 'activities.updated_at DESC'
This apparently prevents me from being able to change the sorting on the resource's index page by clicking on the column titles. Is there a way to keep this default scope but get Active Admin sorting to work?
ActiveAdmin.register Post do
controller do
def scoped_collection
Post.unscoped
end
end
end
scope('all', default: true) { |scope| scope.where(...) }
Try out this solution.
#/admin/user.rb
controller do
# for index page
def active_admin_collection
User.unscoped { super }
end
# for show, edit
def resource
User.unscoped { super }
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With