Ruby on rails 3 rails中带条件联接的活动记录查询 我有Category和Deal模型,有有很多:通过categories映射 我有另一个模型,City,它有一个有很多:通过cities映射与交易

Ruby on rails 3 rails中带条件联接的活动记录查询 我有Category和Deal模型,有有很多:通过categories映射 我有另一个模型,City,它有一个有很多:通过cities映射与交易,ruby-on-rails-3,activerecord,has-many-through,Ruby On Rails 3,Activerecord,Has Many Through,现在我想在第2类和第3类以及第10城市中获取交易 CategoriesDeal.where(:category_id=>[2,3]) 比如现在如何指定城市。我想出了解决方案。。这是: Deal.all(:joins=>[:cities, :categories], :conditions=>["cities.id= ? and categories.id IN (?)",2, [62,43]]).uniq 我想出了解决办法。。这是: Deal.all(:joins=>

现在我想在第2类和第3类以及第10城市中获取交易

CategoriesDeal.where(:category_id=>[2,3])

比如现在如何指定城市。

我想出了解决方案。。这是:

Deal.all(:joins=>[:cities, :categories], :conditions=>["cities.id= ? and categories.id IN (?)",2, [62,43]]).uniq

我想出了解决办法。。这是:

Deal.all(:joins=>[:cities, :categories], :conditions=>["cities.id= ? and categories.id IN (?)",2, [62,43]]).uniq