A way to skip default scopes?

I always avoided the default scopes in Rails, precisely because there was no way of turning them off without resorting to potentially dangerous unscoped method that disables much more than just what I’d want. It would be amazing if default scopes actually could have a label/name so we could disable the specific ones.

As an example, soft delete immediately comes to mind. It would be amazing if I could

class Product < ActiveRecord::Base
  default_scope :not_deleted, -> { where(deleted_at: nil) }
end

# and then in admin
Product.unscoped(:not_deleted) # or different, backwards compatible name for the method
3 Likes