Sha256: e51ff4fb32ac7afc3f4c2a22e76c056a29a738308f89555f7211db86e2758302
Contents?: true
Size: 392 Bytes
Versions: 3
Compression:
Stored size: 392 Bytes
Contents
Spree::Product.class_eval do has_many :favorites, :dependent => :destroy has_many :favorite_users, :through => :favorites, :class_name => 'Spree::User', :source => 'user' def self.favorite joins(:favorites).group('spree_favorites.product_id') end def self.order_by_favorite_users_count(asc=false) order("count(spree_favorites.user_id) #{asc ? 'asc' : 'desc'}") end end
Version data entries
3 entries across 3 versions & 1 rubygems