Sha256: 19f531ebd136c17d5fd0b5f409b257709bb2b14143a0925b55c5c7218889b22f
Contents?: true
Size: 615 Bytes
Versions: 3
Compression:
Stored size: 615 Bytes
Contents
module ShoppingCart class OrderItem < ApplicationRecord belongs_to :productable, polymorphic: true belongs_to :order validates :quantity, presence: true validates :quantity, numericality: { only_integer: true, greater_than_or_equal_to: 1 } delegate :destroy_if_orphant, to: :order after_destroy :destroy_if_orphant def update_amount additional_value summ = quantity + additional_value self.update(quantity: summ) end def item_total quantity * productable.price end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shopping-cart-0.1.2 | app/models/shopping_cart/order_item.rb |
shopping-cart-0.1.1 | app/models/shopping_cart/order_item.rb |
shopping-cart-0.1.0 | app/models/shopping_cart/order_item.rb |