-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
Given:
class Post include Mongoid::Document has_many :comments end class Comment include Mongoid::Document belongs_to :post end
Enum not loaded
1.9.3p392 :006 > p = Post.create => #<Post _id: 51b984bbf52876e795000001, > 1.9.3p392 :007 > p.comments.create => #<Comment _id: 51b984c2f52876e795000002, post_id: "51b984bbf52876e795000001"> 1.9.3p392 :008 > p.comments.new => #<Comment _id: 51b984c7f52876e795000003, post_id: "51b984bbf52876e795000001"> 1.9.3p392 :009 > p.comments.last => #<Comment _id: 51b984c2f52876e795000002,post_id: "51b984bbf52876e795000001">
Enum loaded
1.9.3p392 :011 > p.comments.entries => [#<Comment _id: 51b984c2f52876e795000002,post_id: "51b984bbf52876e795000001">, #<Comment _id: 51b984c7f52876e795000003, post_id: "51b984bbf52876e795000001">] 1.9.3p392 :012 > p.comments._loaded? => true 1.9.3p392 :013 > p.comments.last => #<Comment _id: 51b984c2f52876e795000002, post_id: "51b984bbf52876e795000001">