I’ve embedded all the activities for a user and let’s say most user has tens of thousands of activities associated with them. When checking the current_user in my controller code, does Mongoid load the entire user object containing all the embedded activity records? My gut feeling tells me no but I’d really want to confirm it so I can sleep better at night. 🙂 Thank you!
Below is a short version of the User class.
class User
include Mongoid::Document
embeds_many :activities
end
EDIT
Let me clarify why I’m particularly interested to see if the entire object is loaded when using current_user. Since the activities are embedded in the user document, and most users have thousands of records, each full load would be expensive if all I want is just to check whether the user is signed in or not.
Yup. Devise requests the entire model when authenticating, so Mongoid will give you access to
activitiesif you callcurrent_user.activities.