Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2025

Default scopes apply to other scopes

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • None

      Hey Durran. I just noticed that a model's default scope will be applied if you use unscoped and then a scope. Eg:

      class Porkchop
        include Mongoid::Document
      
        default_scope where(:default => true)
      
        scope :tasty, where(:tasty => true)
      end
      
      Porkchop.unscoped.tasty
      => #<Mongoid::Criteria
        selector: {:default=>true, :tasty=>true},
        options:  {},
        class:    Porkchop,
        embedded: false>
      

      I'd expect Porkchop.unscoped.tasty not to contain the default scope.

            Assignee:
            Unassigned Unassigned
            Reporter:
            nickh Nick Hoffman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: