Sha256: 3f67a78ccac24b2c6226087d48f3199012f6eeebb8efffcca618959754e43b7b

Contents?: true

Size: 385 Bytes

Versions: 2

Compression:

Stored size: 385 Bytes

Contents

module Spree
  class Favorite < ActiveRecord::Base
    attr_accessible :product_id
    belongs_to :product
    belongs_to :user
    validates :user_id, :product_id, :presence => true
    validates :product_id, :uniqueness => { :scope => :user_id, :message => "already marked as favorite" }
    validates :product, :presence => { :message => "is invalid" }, :if => :product_id
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_favorite_products-1.0.1 app/models/spree/favorite.rb
spree_favorite_products-1.0.0 app/models/spree/favorite.rb