9
Company.includes(:branches).where(:branches => {:id => 3})
or
Branch.find(3).companies
UPDATE Actually, there's one downside to the first snippet: it eagerly loads branches along with the companies. To avoid this overhead you may consider using a left join:
Company.
joins("LEFT JOIN `branch_choices` ON `branch_choices`.`company_id` = `companies`.`id`").
where(:branch_choices => {:branch_id => 3})