Administrate and unscoping default scope

400 Views Asked by At

I have a model with a default scope:

default_scope -> { where(is_active: true) }

Can I unscope the model in Administrate, so the I can see all the records in the admin panel?

2

There are 2 best solutions below

0
On BEST ANSWER

You could do:

User.unscope(where: :is_active)

but it would probably be better to just not have a default scope if you are not going to use it everywhere.

link

0
On

You can unscope the where clause using the unscope method. Here's how you'd create a new scope overriding the where clause in default_scope.

scope :including_inactive, ->{ unscope(where: :is_active) }