Paginate and 'Group By' Option

My SQL query also has a ‘group by’ option.

When I try to use paginate, I can find order option. But when I try to
use

:group => ‘customer.id’

It shows that this is an unknown option. I found that paginate does not
have group option.

Anyone has any idea how to add ‘group by customer.id’ into paginate.

Thank you very much for the help.

use the paginating_find plugin (read about it on
http://cardboardrocket.com).
That being said, the count will be wrong so you will need to hack the
find
method to help it figure out how many pages are in the collection.
Here’s
the hack:

Find the code in paginating_find.rb that says:

total_size = limit ? limit : count(options[:conditions],
options[:joins])

Replace it with:

    if block_given?
      total_size = limit ? limit : yield
    else
      total_size = limit ? limit : count(options[:conditions],

options[:joins])
end

Now, when you call find, do it as:

@my_fine_stuff = Model.find(:all, …whateveroptionsyouhave…) {
whatever
it takes to count the records in the collection }

It’s not too economical of SQL queries but it works.

Bryan Roxah wrote:

have group option.


View this message in context:
http://www.nabble.com/Paginate-and-'Group-By'-Option-tf2254447.html#a6259843
Sent from the RubyOnRails Users forum at Nabble.com.