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?
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?
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) }
You could do:
but it would probably be better to just not have a default scope if you are not going to use it everywhere.
link