simpe, but basic active record question

Remco Hh <rails-mailing-list@...> writes:

orderlines=customer.orders.orderlines would be great, but that doesn't
work

The problem is that customer.orders works, but returns a collection of orders.
And a *collection* doesn't have any orderlines.

A good bet would be customer.orders.collect{|o| o.orderlines} which would
collect the orderlines from all of the orders and return them.

You'd end up with an array of arrays (this will only make sense in a fixed width
font:)

  ------- order 1 ------- - order 2 - , ------------- order 3 -------------
[ [orderline1, orderline2], [orderline3], [orderline4, orderline5, orderline6] ]

if you only want the orderlines then you can call
customer.orders.collect{|o| o.orderlines}.flatten which will collapse the above
into one big array.