2

I'm using active admin on a project. I have a request to create a new resource and was given a complex SQL query to use - which connects to a different DB. All is good - however, I'm somewhat new to ActiveAdmin and curious how to get the index page to use my custom query vs. the default resource.

I just need a nudge/sample to see how to override this default activity.

0

1 Answer 1

0

You can declare scopes and filters when registering your model with ActiveAdmin.

app/model/your_model.rb

class YourModel < ActiveRecord::Base
  scope :my_scope, where('some custom SQL')
  scope :my_other_scope, where('some other custom SQL')
end

app/admin/your_models.rb

ActiveAdmin.register YourModel do
  scope :my_scope, default: true
  scope :my_other_scope
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.