samedi 9 janvier 2016

Rails filter records has_many through

I am trying to search an Item model with a filter named genres that are connected by has_many through.

My problem is when I select two genres or more, it also selects records that contain only one genre.

This is my filter statement under the controller

  @item = Item.includes(:genres).where('genres.id' => params['genre_ids'])

Aucun commentaire:

Enregistrer un commentaire