I have two models, one is Repository
the second is Photo
. A repository can have many photo's.
My end goal is to show a set of repositories and a display picture for each repository.
I want to do something like:
@repositories = Repository.limit(10)
repositories_id = @repositories.map &:id
@photos = Photos.where(repository_id: repositories_id)
However this will return multiple photo objects with the same repository_id and I just want the first instance.