-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Major - P3
-
Affects Version/s: 5.2.1
-
Component/s: None
Given two classes:
class User include Mongoid::Document has_many :tasks, dependent: :destroy end class Task include Mongoid::Document belongs_to :user end
Is it possible for an instance of User to auto include itself on each of it's tasks?
user.tasks.map { |t| t.user }
The above example will cause n+1 queries, where n is the number of tasks. Is it possible to just automatically assign user to each task so it doesn't have to do a new lookup each time?
- duplicates
-
MONGOID-2882 Set base relation on has_many enumerable objects
- Closed