Module: ActiveRecord::Acts::ShoppingCartItem::ClassMethods

Defined in:
lib/active_record/acts/shopping_cart_item.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_shopping_cart_itemObject

Alias for:

acts_as_shopping_cart_item_for :shopping_cart


31
32
33
# File 'lib/active_record/acts/shopping_cart_item.rb', line 31

def acts_as_shopping_cart_item
  acts_as_shopping_cart_item_for :shopping_cart
end

#acts_as_shopping_cart_item_forObject

Prepares the class to act as a cart item.

Receives as a parameter the name of the class that acts as a cart

Example:

acts_as_shopping_cart_item :cart


19
20
21
22
23
24
# File 'lib/active_record/acts/shopping_cart_item.rb', line 19

def acts_as_shopping_cart_item_for(*)
  send :include, ActiveRecord::Acts::ShoppingCartItem::InstanceMethods
  belongs_to :owner, polymorphic: true
  belongs_to :item, polymorphic: true
  monetize :price_cents
end