2015-02-06 06:58:16 +01:00
|
|
|
class ItemInCart < ActiveRecord::Base
|
2015-02-07 07:52:32 +01:00
|
|
|
belongs_to :cart
|
|
|
|
|
belongs_to :item
|
|
|
|
|
|
|
|
|
|
validates_uniqueness_of :item_id, scope: :cart_id
|
|
|
|
|
validates :item_id, presence: true
|
|
|
|
|
validates :cart_id, presence: true
|
2015-03-14 06:33:49 +01:00
|
|
|
|
2015-03-14 08:17:06 +01:00
|
|
|
def name
|
2015-04-08 07:35:00 +02:00
|
|
|
if item
|
|
|
|
|
item.name + " " + count.to_s + " " + price.to_s
|
|
|
|
|
else
|
|
|
|
|
" no item "
|
|
|
|
|
end
|
2015-03-14 06:33:49 +01:00
|
|
|
end
|
2015-02-06 06:58:16 +01:00
|
|
|
end
|