我有以下模型类:
class OptionCategory < ActiveRecord::Base
attr_accessible :disabled, :list_index, :name
has_many :options
end
class Option < ActiveRecord::Base
attr_accessible :disabled, :name, :option_category_id
belongs_to :option_category
has_and_belongs_to_many :products
end
class Product < ActiveRecord::Base
attr_accessible :annual_fee, :bal_transfer_intro_apr_end, :bal_transfer_intro_apr_start, :balance_transfer_fee, :description, :image, :image_cache, :name, :pur_intro_apr_end, :pur_intro_apr_start, :sign_up_bonus, :sign_up_bonus_type, :url
mount_uploader :image, ImageUploader
has_and_belongs_to_many :options
end
在我的一个控制器中,我收到一组选项 ID,我想查询具有与这些 ID 匹配的选项的产品。在 Rails 中有没有简单的方法来做到这一点?谢谢!