Module: ActiveRecord::Acts::ShoppingCart::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#acts_as_shopping_cartObject

Alias for:

acts_as_shopping_cart_using :shopping_cart_item


29
30
31
# File 'lib/active_record/acts/shopping_cart.rb', line 29

def acts_as_shopping_cart
  acts_as_shopping_cart_using :shopping_cart_item
end

#acts_as_shopping_cart_using(item_class) ⇒ Object

Prepares the class to act as a cart.

Receives as a parameter the name of the class that will hold the items

Example:

acts_as_shopping_cart :cart_item


19
20
21
22
# File 'lib/active_record/acts/shopping_cart.rb', line 19

def acts_as_shopping_cart_using(item_class)
  self.send :include, ActiveRecord::Acts::ShoppingCart::InstanceMethods
  has_many :cart_items, :class_name => item_class.to_s.classify, :as => :owner
end