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
I'm using Rails 4.1.7 and the accepted answer did not work for me. What did work is
Report.joins(:server).where(:servers => {:company_id => 5})
Note that the difference is the key in the where clause is pluralized (:servers instead of :server)