I have 2 models. Report and Server that have a belongs_to and has_many relationship. I created an accessor method using delegate that
Report
Server
delegate
You can perform a query like this:
Report.joins(:servers).where(:servers => {:company_id => 5})
To me, this is the cleaner solution to raw SQL.