Materialize active record object with included associations

Hi

I have a basic active query like so:

m = Movie.includes(:genres)


m.genders is an CollectionProxy in this case. Is there a way I can get this as an array?

I know that calling to_a will do this, but this becomes impractical for a bunch of includes.

The problem that I am having is that when I cache m in redis after fetching it the genres query is done again if I don’t iterate the collection.

Regards,

to_a is the way to do this - why do you say this is impractical?

Fred

Try
m = Movie.map(&:genders).includes(:genres)