I would
```ruby
where :id => repos.inject([]) { |ids, repo| ids.push repo.library_instance_id || repo.id } 
```