Skip to content

Instantly share code, notes, and snippets.

@rocodev-tech
Created June 12, 2014 22:05
Show Gist options
  • Save rocodev-tech/041b90869fbbe7902a68 to your computer and use it in GitHub Desktop.
Save rocodev-tech/041b90869fbbe7902a68 to your computer and use it in GitHub Desktop.
app/models/cart.rb
class Cart < ActiveRecord::Base
has_many :cart_items, :dependent => :destroy
has_many :items, :through => :cart_items, :source => :product
def add_product_to_cart(product)
items << product
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment