I\'m a PHP developer learning the awesomness of Ruby on Rails, I\'m loving ActiveRecord and i noticed something really interesting, Which is how ActiveRecord methods detect
There are a number of methods that are known as "kickers" that actually fire off the query to the database. Prior to that, they just create AST nodes, which once kicked, will generate the actual SQL (or language being compiled to) and run the query.
See this blog post for a deeper explanation of how this is done.