Rails gives us a great DSL for constructing most queries. With its knowledge of
the relationships between our tables, it’s able to construct join clauses with
nothing more than the name of a table. It even aliases your tables
automatically!

The method…

Read more at the source