17 lines
326 B
Ruby
17 lines
326 B
Ruby
class ItemInCart < ActiveRecord::Base
|
|
belongs_to :cart
|
|
belongs_to :item
|
|
|
|
validates_uniqueness_of :item_id, scope: :cart_id
|
|
validates :item_id, presence: true
|
|
validates :cart_id, presence: true
|
|
|
|
def name
|
|
if item
|
|
item.name + " " + count.to_s + " " + price.to_s
|
|
else
|
|
" no item "
|
|
end
|
|
end
|
|
end
|