Sha256: 368cb2a0c660740b65369d4b875d891158d87948d498a682320ceb6103dcd38e
Contents?: true
Size: 336 Bytes
Versions: 2
Compression:
Stored size: 336 Bytes
Contents
Spree::Product.class_eval do has_many :favorites, dependent: :destroy has_many :favorite_users, through: :favorites, class_name: 'Spree::User', source: :user scope :favorite, -> { joins(:favorites).distinct } scope :order_by_favorite_users_count, ->(asc = false) { order(favorite_users_count: "#{asc ? 'asc' : 'desc'}") } end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
spree_favorite_products-3.2.0 | app/models/spree/product_decorator.rb |
solidus_favorite_products-2.1.1 | app/models/spree/product_decorator.rb |