Finding out how many assets each user has


#1

I’m sure this is a dumb question, but how could I find out how many
assets (or anything that belongs to a user) each user has? I can only
think of looping through each user and adding the asset size to an
array, but when you have thousands of users, that can take a lot of
time and memory. Thanks for the help.


#2

user.assets.size will do the trick. The query that’s issued will look
something like

SELECT count(*) AS count_all FROM assets WHERE (assets.user_id =
7524)

Regards,
Craig