Ruby on Rails Thursday, July 2, 2015



On Thursday, July 2, 2015 at 9:50:55 AM UTC+1, Alexandru Calinoiu wrote:

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.


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

Fred 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/79e36931-e486-40a5-a8ff-659bba9e2c71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment