In my Store model I have the following:
class Store < ActiveRecord::Base
has_many :categorizations
has_many :categories, :through => :categorizations
scope :by_categories, lambda{|category_ids|
where(*stores have the following* => category_ids) unless category_ids.empty?
}
I’m looking to setup a scope where I can send it multiple or a single category ID and have the scope return stores that belong to all the categories specified.
Thank you for looking.
1 Answer