mongoid/mongoid — Issue #1636: Two models inheriting from same parent.  scope added to one effects the other.
Author: gavinhughes
Created: 2012-01-24 01:23:23+00:00
State: open

class User
scope :confirmed, where(:confirmed_at.gt => 0)

class Sponsor < User
scope :homepage, confirmed.where('offers.amount' => { '$gt' => 0 })

class Owner < User
scope :homepage, confirmed

# Checking the results...
>> Owner.homepage.count
=> 0

# Remove part of the scope on Sponsor...
scope :homepage, confirmed #.where('offers.amount' => { '$gt' => 0 })

# Changes the behavior of Owner...
>> reload!
Reloading...
=> true
>> Owner.homepage.count
=> 51