Company.includes(:branches).where(:branches => {:id => 3})
or
Branch.find(3).companies
UPDATE In fact, there is one drawback of the first fragment: it readily downloads branches along with companies. To avoid this overhead, you can use the left join:
Company. joins("LEFT JOIN `branch_choices` ON `branch_choices`.`company_id` = `companies`.`id`"). where(:branch_choices => {:branch_id => 3})
source share