【发布时间】:2016-12-11 20:52:10
【问题描述】:
class Product < ActiveRecord::Base
has_and_belongs_to_many :product_categories
end
class ProductCategory < ActiveRecord::Base
has_and_belongs_to_many :products
end
我有一个产品类别数组,我需要选择属于数组中某个类别的所有产品
谢谢,Rotem
【问题讨论】:
-
这样的?
product_categories.each { |pr| pr.products }
标签: ruby-on-rails ruby-on-rails-4 where