Created
June 12, 2014 22:05
-
-
Save rocodev-tech/041b90869fbbe7902a68 to your computer and use it in GitHub Desktop.
app/models/cart.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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