我遇到了一些问题!我有通过has_and_belongs_to_many连接的Place模型和Category模型。我希望能够过滤出属于给定数组中至少一个类别的所有地方(int数组的ids)。到目前为止,我只能够通过一个单一的类别用下面的代码进行过滤:Rails按has_and_belongs_to_many属性过滤
@places = Place.find(:all, :include => :categories, :conditions => { "categories_places.category_id" => id})
所以基本上,而不是ID的我想要的ID。我希望这里有一些能够帮助的专家!我对此很陌生。
谢谢你和@ bor1s为快速反应。我不能尝试解决方案,直到明天,但我毫不怀疑它应该工作:)不幸的是,我不能upvote,因为太低代表:( – Cesar