Reputation: 43919
Category
and Deal
and having has_many :through
mapping via categories_deals
. City
, which has a has_many :through
mapping via cities_deals
with deals
.Now I want to fetch deals in category 2 and 3 and city 10.
CategoriesDeal.where(:category_id=>[2,3])
Like how to specify city now.
Upvotes: 1
Views: 1808
Reputation: 43919
I figured out the solution.. Here it is:
Deal.all(:joins=>[:cities, :categories], :conditions=>["cities.id= ? and categories.id IN (?)",2, [62,43]]).uniq
Upvotes: 1