I would
```ruby
joins(:repositories).where(:repositories => {:id => repo.id})
```