Sha256: af3193b147a3c4ddd83ec0e37b9bac3fdecc77b59fd855e6f5b25b11a31568ce
Contents?: true
Size: 969 Bytes
Versions: 10
Compression:
Stored size: 969 Bytes
Contents
module MageRecord # order items can be parents / children of other order items # (only within the same order) class OrderItem < ActiveRecord::Base self.table_name = :sales_flat_order_item belongs_to :order belongs_to :parent, class_name: :OrderItem, foreign_key: :parent_item_id belongs_to :product # note: add an index on the column "parent_item_id" to # *dramatically* speed up loading of child order items from the parent order item has_many :children, class_name: :OrderItem, foreign_key: :parent_item_id # call associated product's method def method_missing(meth, *args, &block) if product && product.respond_to?(meth) product.send(meth) else # call superclass's method_missing method # or risk breaking Ruby's method lookup super end end def respond_to?(meth, include_private = false) super || (product && product.respond_to?(meth)) end end end
Version data entries
10 entries across 10 versions & 1 rubygems