I have found in several resources online than when doing stuff like:
cars = Car.where(:colour => \'black\')
The query is not executed, until
This is an interesting question....The answer is that when executing something in IRB/console, it calls inspect on the resulting object and then prints it out. If you did something like:
User.where(:first_name => "John").class
you should get back an ActiveRecord::Relation object.
So the lazy loading for Rails still holds, it's just the way the console works.
Hope this helps.
Source(s): 1) https://rails.lighthouseapp.com/projects/8994/tickets/4951-rails-console-executes-where-queries-without-lazy-loading 2) Why Active Record relation is not returned in console?