adric: books icon (c) 2004 adric.net (Default)
adric ([personal profile] adric) wrote2008-11-19 06:25 pm
Entry tags:

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

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org