-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
Using: 4.0.0.beta1
Given:
class School include Mongoid::Document has_many :students end class Student include Mongoid::Document belongs_to :school scope :enrolled, -> { where(state: 'enrolled') } end school = School.new student = school.students.build() student.school == school # => true
Then if I use a scope, say enrolled, I might expect similar behavior, except I get:
school = School.new student = school.students.enrolled.build() student.school == school # => false student.school.nil? # => true student.state # => "enrolled", expected behavior for this scope
So the parent of the relation doesn't stay attached to the new child when using a scope.