Where Any? vs Exists? Discussion
I don't think this is true. any?
does the same optimization by itself. The reason you got a full association loaded on the first command is because of the rails console trying to output something which triggers the query. In regular application code cluster.domains.where(name: 'foo.com')
would not trigger a query yet and wait until something like each
or any?
is sent. You can try this by appending ;nil
to console commands: cluster.domains.where(name: 'foo.com');nil
Yeah I should have mentioned that in the video so that was a detail oversight on my part. I was planning to update this video to mention it. Thank you for commenting about it though so others can be aware of it until I get an update out!