Sha256: 9169b4aa6bc90a9627b4047bbf60b1d1c5a7f5c59bb5c5c1ab8996b5bbc946e7
Contents?: true
Size: 589 Bytes
Versions: 1
Compression:
Stored size: 589 Bytes
Contents
class CartItem < ActiveRecord::Base belongs_to :variant belongs_to :cart validates_presence_of :variant, :quantity validates_numericality_of :quantity, :only_integer => true, :message => "must be an integer" def validate unless quantity && quantity >= 0 errors.add(:quantity, "must be a positive value") end unless quantity <= 100000 errors.add(:quantity, "is too large") end end def increment_quantity self.quantity += 1 end def decrement_quantity self.quantity -= 1 end def price self.variant.price end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spree-0.2.0 | app/models/cart_item.rb |