Ruby on Rails Thursday, August 25, 2016

On Wednesday, August 24, 2016 at 1:49:48 PM UTC+1, Bazley wrote:
The first thing I do with it is this:

if @new_relationships.any?

So it looks like .any? affects the query? I would have thought rails would perform the query, get all the records into @new_relationships, and then count them. This is a surprising feature.

What rails is trying to avoid is loading 1000 objects from the db, just to check whether there is > 0 objects. If the query had already run, then it would just could the loaded objects. 


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
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment