4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/models/spree/multi_store/promotion_decorator.rb', line 4
def self.prepended(base)
base.has_many :store_promotions, class_name: 'Spree::StorePromotion'
base.has_many :stores, through: :store_promotions, class_name: 'Spree::Store'
base.scope :for_store, ->(store) { joins(:store_promotions).where(StorePromotion.table_name => { store_id: store.id }) }
base.whitelisted_ransackable_associations =
(base.whitelisted_ransackable_associations.to_a + %w[stores store_promotions]).uniq
base.include Spree::MultiStoreResource
end
|