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:>
>
> 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.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
>
--
View this message in context:
http://www.nabble.com/Paginate-and-%27Group-By%27-Option-tf2254447.html#a6259843
Sent from the RubyOnRails Users forum at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---