I need help in ActiveRecord

I have this Product.find(:all, :include => [:brand, :category, :type],
:group =>
“description”), but it dont group by description why?

Bruno

On Apr 19, 2006, at 05:16 PM, String numecal validate! wrote:

I have this Product.find(:all, :include => [:brand, :category, :type],
:group =>
“description”), but it dont group by description why?

When ever you use :include in a fine, you have to disambiguate all of
your column references with the rest of the find options. So, if
description is part of products, then you have to do :group =>
“products.description”, in order for it to work properly.

-Brian

Brian V Hughes wrote:

On Apr 19, 2006, at 05:16 PM, String numecal validate! wrote:

I have this Product.find(:all, :include => [:brand, :category, :type],
:group =>
“description”), but it dont group by description why?

When ever you use :include in a fine, you have to disambiguate all of
your column references with the rest of the find options. So, if
description is part of products, then you have to do :group =>
“products.description”, in order for it to work properly.

-Brian

That is not worked.I’am using this Product.find(:all, :include =>
[category], :group => “products.description”)
And saw in log the query
SELECT products.id AS t0_r0, products.entity_company_id AS t0_r1,
products.product_brand_id AS t0_r2, products.product_category_id AS
t0_r3, products.product_type_id AS t0_r4, products.code AS t0_r5,
products.description AS t0_r6, products.characteristics AS t0_r7,
products.cf AS t0_r8, products.cd AS t0_r9, products.cn AS t0_r10,
products.pisc AS t0_r11, products.icms AS t0_r12, products.ipi AS
t0_r13, products.mar AS t0_r14, products.active AS t0_r15,
product_categories.id AS t1_r0, product_categories.product_brand_id
AS t1_r1, product_categories.description AS t1_r2,
product_categories.active AS t1_r3 FROM products LEFT OUTER JOIN
product_categories ON product_categories.id =
products.product_category_id

Thank’s

Bruno