2
votes

I have a model where the default scope shows only records with status set to 0:

default_scope where(status: 0)

This works fine, and when I display all the records in an ActiveAdmin page, it only the shows the ones with a status of 0. However, I would like to create another page in the admin panel that shows all the records, unscoped. Right now, I have:

ActiveAdmin.register Donation, as: "All Donations" do

  scope_to :unscoped

  index :title => "Donations" do
    ...

But I'm getting this error:

undefined method `unscoped' for #<Admin::AllDonationsController:0x007feac043d638>

This still seems to happen if I give the scope a different name in the model. How can I resolve this?

1
What's your version of ActiveAdmin? There was a similar issue a while back: github.com/gregbell/active_admin/issues/70 - Joshua Scott
I'm using version 0.6.0 - Andrew

1 Answers

2
votes

I was able to get what I wanted by adding this to the register block for donations:

controller do
  def scoped_collection
    Donation.unscoped
  end
end

I still don't understand why ActiveAdmin can't see scopes you define in the model file