Hi ! I''m looking for help to choose a pagination solution. As the built-in pagination is not very practical and will be soon deprecated, I was trying to finc something else. My problem is that most solutions (for example paginating_find) will replace the find method to add stuff. However, I''d like to find a more "flexible" solution, as I sometimes have to apply treatment to the retreived data. For example, I have a query that uses ''OR'' to search on two different fields of the model, and I then use results.uniq! to remove duplicates. Of course, the pagination should apply to theses results, and not on the find result. I could put my uniq in the sql code (or use filters, but I need this in only one place in the app), but I think I could be more flexible if I could apply pagination on any array and not only the result of a find query. what''s your opinion about the best way to solve this issue ? Thanks in advance, Nicolas -- Posted via http://www.ruby-forum.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?hl=en -~----------~----~----~----~------~----~------~--~---
Just use will_paginate On 8/24/07, Nicolas Niconoe <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi ! > > I''m looking for help to choose a pagination solution. As the built-in > pagination is not very practical and will be soon deprecated, I was > trying to finc something else. > > My problem is that most solutions (for example paginating_find) will > replace the find method to add stuff. However, I''d like to find a more > "flexible" solution, as I sometimes have to apply treatment to the > retreived data. For example, I have a query that uses ''OR'' to search on > two different fields of the model, and I then use results.uniq! to > remove duplicates. Of course, the pagination should apply to theses > results, and not on the find result. I could put my uniq in the sql code > (or use filters, but I need this in only one place in the app), but I > think I could be more flexible if I could apply pagination on any array > and not only the result of a find query. > > what''s your opinion about the best way to solve this issue ? > > Thanks in advance, > > Nicolas > -- > Posted via http://www.ruby-forum.com/. > > > >-- Cheers! - Pratik http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Well, when I read will_paginate documentation, I still have the feeling that''s it''s designed to replace the find method, and not to (more genrally) handle a container. Taken from the will_paginate README : @posts = Post.paginate_by_board_id @board.id, :page => params[:page] Yeah, +paginate+ works just like +find+ -- it just doesn''t fetch all the records. Just don''t forget to tell it which page you want! Pratik Naik wrote:> Just use will_paginate > > On 8/24/07, Nicolas Niconoe <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> retreived data. For example, I have a query that uses ''OR'' to search on >> >> Nicolas >> -- >> Posted via http://www.ruby-forum.com/. >> >> > >> > > > -- > Cheers! > - Pratik > http://m.onkey.org-- Posted via http://www.ruby-forum.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?hl=en -~----------~----~----~----~------~----~------~--~---
On 8/24/07, Nicolas Niconoe <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Well, when I read will_paginate documentation, I still have the feeling > that''s it''s designed to replace the find method, and not to (more > genrally) handle a container.There''s another plugin called "paginator" which you can read information about here: http://rubyforge.org/projects/paginator. From the Readme <http://viewvc.rubyforge.mmmultiworks.com/cgi/viewvc.cgi/trunk/README.txt?view=markup&root=paginator&pathrev=14>: "Paginator doesn''t make any assumptions as to how data is retrieved; you just have to provide it with the total number of objects and a way to pull a specific set of objects based on the offset and number of objects per page." which seems like what you want. Personally, I use will_paginate, since it adds a nice view method for you to automatically display the page links with a single line of code, nd you don''t need to count the number of objects manually like you do in paginator (I haven''t used paginator, so I''m just going by what''s in the readme file) will_paginate is pretty flexible in the way it works, if you need information on using it for complex queries (such as with scope-out-rails), check out the following site: http://zargony.com/2007/07/21/paginating-special-queries/ Adam --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Just for the sake of offering another option: there''s also another major player in the pagination plugin game, paginating_find [ http://cardboardrocket.com/pages/paginating_find ]. Among the Rails developers I know it seems around half of us are using it. It''s completely a matter of style but I find paginating_find''s interface to be a tad more elegant. They pretty much do the same things, just in slightly different ways. :) And I always feel like it''s nice to have options to choose from instead of only being offered one solution. RSL On 8/24/07, Mike Garey <random52k-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 8/24/07, Nicolas Niconoe <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > Well, when I read will_paginate documentation, I still have the feeling > > that''s it''s designed to replace the find method, and not to (more > > genrally) handle a container. > > There''s another plugin called "paginator" which you can read > information about here: http://rubyforge.org/projects/paginator. From > the Readme < > http://viewvc.rubyforge.mmmultiworks.com/cgi/viewvc.cgi/trunk/README.txt?view=markup&root=paginator&pathrev=14 > >: > > "Paginator doesn''t make any assumptions as to how data is retrieved; you > just > have to provide it with the total number of objects and a way to pull a > specific > set of objects based on the offset and number of objects per page." > > which seems like what you want. Personally, I use will_paginate, > since it adds a nice view method for you to automatically display the > page links with a single line of code, nd you don''t need to count the > number of objects manually like you do in paginator (I haven''t used > paginator, so I''m just going by what''s in the readme file) > > will_paginate is pretty flexible in the way it works, if you need > information on using it for complex queries (such as with > scope-out-rails), check out the following site: > > http://zargony.com/2007/07/21/paginating-special-queries/ > > Adam > > > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---