November 19th, 2008

Books

Another day in #rubyonrails ...

After being in the channel since this: Collapse )

and another couple instances of non-help, until I finally annoy and offend enough people that they become more helpful? Fiik:

Collapse )

took a break to make this post and laugh ...

Collapse )

Currently fighting the syntax on that/those suggestions ... Gods but I hate this crap (joins). It never makes a lick of sense to me (ER) and hardly every works right. Blech.

Books

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