Displaying 1 result from an estimated 1 matches for "in_preparation".
2011 Jun 04
0
Rails 3.1 : Complex database query with Arel 2
...d, sum(quantity) as stock
from "deposits"
where validated = true
group by asset_id
) as stocks
on assets.id = stocks.asset_id
join
(
select asset_id, sum(quantity) as ordered
from order_lines
join orders on orders.id = order_id
where state in (''IN_PREPARATION'', ''WAIT_DELIVERY'')
group by asset_id
) as ordereds
on assets.id = ordereds.asset_id
I expect to retrieve a simple hash with results so I''ve tried to do that
directly with Arel but is there a way to do that with ActiveRecord ?
Thanks in advance.
--
Y...