I’m actually wondering why you’re finding the categories that belong
to a given
user in the manner that you’ve shown us. You’ve gone through all that
define your user -> category relationship why not use it?
user = User.find(1)
@userCategories = user.categories
I see you’re prefetching notes as well so you can add that to your
relationship declaration if
you really need them.
Anyway, not saying your usage isn’t for good reason but given the
context it sorta jumps out
at me that you’re not using the association for what’s essentially
the same exact query as you’re building by hand.