How to use GROUP BY clause with Active Record Paginate

I am trying to use the ActiveRecord paginate function with a :joins
option, fine I get all records I want, but I need to get rid of
duplicated records in the table, so I would like to use the GROUP BY
mytable.id…
as there is no :group option (why ?) I tried to insert it in the
:conditions…or in the :joins strings…
it failed…

how can I do it ? is it possible ? if not why this option could not be
made available in paginate ?
if it’s not possible should I rather use a kind of ‘paginate_from_sql’
method ?

kad

Kad K. wrote:

I am trying to use the ActiveRecord paginate function with a :joins
option, fine I get all records I want, but I need to get rid of
duplicated records in the table, so I would like to use the GROUP BY
mytable.id…
as there is no :group option (why ?) I tried to insert it in the
:conditions…or in the :joins strings…
it failed…

how can I do it ? is it possible ? if not why this option could not be
made available in paginate ?
if it’s not possible should I rather use a kind of ‘paginate_from_sql’
method ?

kad

that’s exactly the SOLUTION !
thanks to…

http://thebogles.com/blog/2006/06/paginate_by_sql-for-rails-a-more-general-approach/