Sha256: 5dc4c01717a18beae54b9d4814dcc2d583c654371aaf7ecaf0834547118bac5a
Contents?: true
Size: 417 Bytes
Versions: 2
Compression:
Stored size: 417 Bytes
Contents
module Spree class Favorite < ActiveRecord::Base with_options required: true do belongs_to :product, counter_cache: :favorite_users_count belongs_to :user end validates :product_id, uniqueness: { scope: :user_id, message: Spree.t(:duplicate_favorite), allow_blank: true } scope :with_product_id, ->(id) { joins(:product).readonly(false).merge(Spree::Product.where(id: id)) } end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
spree_favorite_products-3.2.0 | app/models/spree/favorite.rb |
solidus_favorite_products-2.1.1 | app/models/spree/favorite.rb |