Sha256: 8eeb17d4f20a684cb64d7fa6a4a6a91bad6e53552e9c9a34af434b9a2c7a536b

Contents?: true

Size: 280 Bytes

Versions: 4

Compression:

Stored size: 280 Bytes

Contents

Spree::User.class_eval do 
  has_many :favorites, :dependent => :destroy
  has_many :favorite_products, :through => :favorites, :class_name => 'Spree::Product', :source => 'product'

  def has_favorite_product?(product_id)
    favorites.exists? :product_id => product_id
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spree_favorite_products-2.3.0 app/models/spree/user_decorator.rb
spree_favorite_products-3.0.0 app/models/spree/user_decorator.rb
spree_favorite_products-2.0.3 app/models/spree/user_decorator.rb
spree_favorite_products-2.2.3 app/models/spree/user_decorator.rb