single method for updating cart item state / fixed problems with sinatra contrib

This commit is contained in:
Senad Uka
2015-02-07 07:52:32 +01:00
parent c515e400e7
commit a642cb55eb
7 changed files with 39 additions and 21 deletions

View File

@@ -1,6 +1,5 @@
class Cart < ActiveRecord::Base
has_many :item_in_carts
has_many :item_in_carts, -> { order "created_at" }
def self.find_or_create(anonymous_id, user_id)
cart = Cart.where(user_id: user_id).where(ordered: false).first
cart ||= Cart.where(anonymous_id_string: anonymous_id).where(ordered: false).first