nil.enroll(aetheric_username, quantum_class_id) (adric) wrote,
nil.enroll(aetheric_username, quantum_class_id)
adric

Zencart as seen by Rails?

The fruit of today's labour:
zc_order Order:
  has_one :customer, :foreign_key => "customers_id"
  has_many :orderproducts, :class_name => 'OrderProduct', :foreign_key => 'orders_id'
  has_many :products, :through => :orderproducts

zc_customers Customer:
  has_many :orders, :class_name => 'Order', :foreign_key => 'order_id'

zc_customers Product:
  has_many :orders, :class_name => 'Order', :foreign_key => 'orders_id'
  has_one :productdescription, :class_name => "ProductDescription",
    :foreign_key => 'products_id'
  has_many :orders

zc_products_description ProductDescription
  has_one :productdescription, :class_name => "ProductDescription",
    :foreign_key => 'products_id'

zc_orders_products OrderProduct:
  belongs_to :order, :foreign_key => "orders_id"
  belongs_to :product, :foreign_key => "products_id" 
this works:
>> @summary = Order.all.collect do |@o| 'Order: ' + @o.orders_id.to_s + ' was: ' + @o.products.collect do |@prod| @prod.products_id.to_s + ' ' + @prod.productdescription.products_name end.to_s + ' for: ' + @o.customers_name end
Tags: rails
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments