find() takes a :joins parameter to let you do… well, joins. Its
documented in the API docs. It might be a little easier to work with
than find_by_sql().
Actually, I’d say the answer to Jason’s question is, neither. The
“Rails Way” of doing this kind of search is through the :include
option to the standard find method. Based on Jasons brief explanation
it looks like he has two models: Winery and Wine, where Winery
has_many: wines and Wine belongs_to: winery.
Given that, his find is to get all Wineries, and their associated
Wines, based on a name sub-string:
That will give you an array of Winery objects, each of which will
have a wines method, which will be an array containing all of the
wines for that Winery…
-Brian
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.