Hi, here’s a snippet from section 17.5 of ‘Agile Web Development with Rails 2ed’.
The :joins parameter to the finder method lets you specify a list of additional
tables to be joined to the default table. This parameter is inserted into the
SQL immediately after the name of the model’s table and before any conditions
specified by the first parameter. The join syntax is database-specific. The
CRUD—CREATE, READ, UPDATE, DELETE 286
following code returns a list of all line items for the book called Programming
:conditions => “pr.title = ‘Programming Ruby’”,
:joins => “as li inner join products as pr on li.product_id = pr.id”)
As we’ll see in Chapter 18, Active Record Part II
Relationships Between Tables, on page 306, you probably won’t use the :joins
parameter of find( ) very much—Active Record handles most of the common
intertable joins for you.