-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
I'm seeing this behavior in mongoid 3 when using eager loading with default scopes. I'm not sure if it's a bug or by design.
Simple example:
class Person include Mongoid::Document field :name has_many :hobbies end
class Hobby include Mongoid::Document field :name field :status belongs_to :person default_scope where(:status.ne => 'deleted') end
After creating a person and two hobbies, one of them with status = 'deleted', person = Person.includes(:hobbies).first correctly performs the eager load query (including the default scope), but then person.hobbies hits the database again. Removing the default scope causes it to work as expected.