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

Use sublcass context when calling a scope defined in a superclass

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

      Example:

      class Shape
        scope :visible, -> { large }
        scope :large, -> { all }
      end
      
      class Circle < Shape
        scope :large, -> { where(radius: 5) }
      end
      

      Circle.visible.selector returns {}, instead of {{

      { "radius" => 5 }

      }}.

      ActiveRecord also uses instance_exec when calling scopes.

      This should also fix MONGOID-3599.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ebeigarts Edgars Beigarts
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: