I''ve just read three* different messages on the list, all posted within a day of each other, and all having problems with the same thing - rails built in pagination. The common misconception seems to be that rails built in pagination works as follows: # grab a list of all the females @users = User.find(:all, :conditions => [''gender = ?'', ''F'']) # paginate the list: @user_pages, @users = paginate(:users, :per_page => 10) The above will paginate a list of users, however, it will NOT have the conditions applied to it that you specified in the first find statement (grabbing a list of females). The two statements are not related to each other. The first finds all the females and stores the results in the @users instance variable. The second finds and paginates _ALL_ of the users and stores them in the @users ivar, overwriting the original contents. This is most likely _not_ what you want. If you wanted to paginate a list of all the females, the correct way to do it is the following # paginate a list of females @user_pages, @users = paginate(:users, :conditions => [''gender = ?'', ''F''], :per_page => 10) now, having said that, please be aware that the rails built in pagination has been deprecated! (see here for more details http://dev.rubyonrails.org/changeset/6992) In other words, do not use it for future projects! Instead, you should be using something like the will_paginate plugin (you can read about it here: http://errtheblog.com/post/4791) Hopefully this will help reduce some confusion.. Mike * the messages I''m referring to.. http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/92190b21dc5c08f5/f4849b96c2b5a943#f4849b96c2b5a943 http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/63d0aee496998a99/a415d6df0fbb6957#a415d6df0fbb6957 http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/fcb0000ac2959193/80bc69f22efdf44f#80bc69f22efdf44f --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
gene.tani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-12 23:01 UTC
Re: Newbies: Read this before asking about pagination
On Jul 12, 2:43 pm, "Mike Garey" <random...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve just read three* different messages on the list, all posted > within a day of each other, and all having problems with the same > thing - rails built in pagination. > > The common misconception seems to be that rails built in pagination > works as follows: > > # grab a list of all the females > @users = User.find(:all, :conditions => [''gender = ?'', ''F'']) > > # paginate the list: > @user_pages, @users = paginate(:users, :per_page => 10) > > The above will paginate a list of users, however, it will NOT have the > conditions applied to it that you specified in the first find > statement (grabbing a list of females). The two statements are not > related to each other. The first finds all the females and stores the > results in the @users instance variable. The second finds and > paginates _ALL_ of the users and stores them in the @users ivar, > overwriting the original contents. This is most likely _not_ what you > want. > > If you wanted to paginate a list of all the females, the correct way > to do it is the following > > # paginate a list of females > @user_pages, @users = paginate(:users, :conditions => [''gender = ?'', > ''F''], :per_page => 10) > > now, having said that, please be aware that the rails built in > pagination has been deprecated! (see here for more detailshttp://dev.rubyonrails.org/changeset/6992) In other words, do not use > it for future projects! > > Instead, you should be using something like the will_paginate plugin > (you can read about it here:http://errtheblog.com/post/4791) > > Hopefully this will help reduce some confusion.. > > Mike > > * the messages I''m referring to..http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/... > > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/... > > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/...good writeup, i think this would be worthwhile for the FAQ (assuming the author wants to start building out the page: http://www.faisal.com/docs/ror-list-faq.html --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
another great alternative is the paginator gem. http://paginator.rubyforge.org/ On 7/12/07, gene.tani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <gene.tani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Jul 12, 2:43 pm, "Mike Garey" <random...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''ve just read three* different messages on the list, all posted > > within a day of each other, and all having problems with the same > > thing - rails built in pagination. > > > > The common misconception seems to be that rails built in pagination > > works as follows: > > > > # grab a list of all the females > > @users = User.find(:all, :conditions => [''gender = ?'', ''F'']) > > > > # paginate the list: > > @user_pages, @users = paginate(:users, :per_page => 10) > > > > The above will paginate a list of users, however, it will NOT have the > > conditions applied to it that you specified in the first find > > statement (grabbing a list of females). The two statements are not > > related to each other. The first finds all the females and stores the > > results in the @users instance variable. The second finds and > > paginates _ALL_ of the users and stores them in the @users ivar, > > overwriting the original contents. This is most likely _not_ what you > > want. > > > > If you wanted to paginate a list of all the females, the correct way > > to do it is the following > > > > # paginate a list of females > > @user_pages, @users = paginate(:users, :conditions => [''gender = ?'', > > ''F''], :per_page => 10) > > > > now, having said that, please be aware that the rails built in > > pagination has been deprecated! (see here for more detailshttp://dev.rubyonrails.org/changeset/6992) In other words, do not use > > it for future projects! > > > > Instead, you should be using something like the will_paginate plugin > > (you can read about it here:http://errtheblog.com/post/4791) > > > > Hopefully this will help reduce some confusion.. > > > > Mike > > > > * the messages I''m referring to..http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/... > > > > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/... > > > > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/... > > good writeup, i think this would be worthwhile for the FAQ (assuming > the author wants to start building out the page: > > http://www.faisal.com/docs/ror-list-faq.html > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I am looking to setup a "test deployment" server for rails and I was wondering everyone input on which is a good solution to work on. According to litespeed using only their server with ruby-lsapi is the ONLY way to go :-P I would just like some realworld experience. Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I am looking to setup a "test deployment" server for rails and I was wondering everyone input on which is a good solution to work on. According to litespeed using only their server with ruby-lsapi is the ONLY way to go :-P I would just like some realworld experience. Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
we use apache + mongrel at work. easy setup and we have never had a problem. no experience with litespeed. good luck in your decision. On 7/12/07, Ronald Valente <rawn027-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am looking to setup a "test deployment" server for rails and I was > wondering everyone input on which is a good solution to work on. > > According to litespeed using only their server with ruby-lsapi is the > ONLY way to go :-P > > I would just like some realworld experience. > > Thanks! > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Do you have any pointers on setting this up? I have a FreeBSD server which I am quite fluent with. Not so much with apache or mongrel. Regards, Ron On Jul 12, 2007, at 9:35 PM, Chris Hall wrote:> > we use apache + mongrel at work. easy setup and we have never had a > problem. no experience with litespeed. > > good luck in your decision. > > On 7/12/07, Ronald Valente <rawn027-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> I am looking to setup a "test deployment" server for rails and I was >> wondering everyone input on which is a good solution to work on. >> >> According to litespeed using only their server with ruby-lsapi is the >> ONLY way to go :-P >> >> I would just like some realworld experience. >> >> Thanks! >> >>> >> > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ron, I run multiple environments (apache + mongrels, apache + litespeed, litespeed only) and I can''t tell you nothing beats litespeed in how easy it is to setup and how fast and stable it is. Recently I benchmarked one of my apps both with mongrel, mongrel + evented and litespeed and LS was not only faster but required less RAM. My mongrel processes started at 33MB and grew into 60-70MB while the Ruby processes under LS stayed at 33MB. And we are talking under sets of 100K requests on 5/10/50 concurrent requests. For me there is no discussion now, LS all the way. Hope it helps, Adrian Madrid On 7/12/07, Ronald Valente <rawn027-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Do you have any pointers on setting this up? I have a FreeBSD server > which I am quite fluent with. Not so much with apache or mongrel. > > Regards, > Ron > > > On Jul 12, 2007, at 9:35 PM, Chris Hall wrote: > > > > > we use apache + mongrel at work. easy setup and we have never had a > > problem. no experience with litespeed. > > > > good luck in your decision. > > > > On 7/12/07, Ronald Valente <rawn027-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >> I am looking to setup a "test deployment" server for rails and I was > >> wondering everyone input on which is a good solution to work on. > >> > >> According to litespeed using only their server with ruby-lsapi is the > >> ONLY way to go :-P > >> > >> I would just like some realworld experience. > >> > >> Thanks! > >> > >>> > >> > > > > > > > > > >-- Adrian Esteban Madrid --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
How well did the Apache + Mongrel do? I have a similar situation as the OP but I have less options at this time to experiment with. The only 2 I really have right now is Apache + Mongrel or Apache + FCGI. TIA, Richard On 7/13/07, Adrian Madrid <aemadrid-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Ron, > > I run multiple environments (apache + mongrels, apache + litespeed, > litespeed only) and I can''t tell you nothing beats litespeed in how > easy it is to setup and how fast and stable it is. Recently I > benchmarked one of my apps both with mongrel, mongrel + evented and > litespeed and LS was not only faster but required less RAM. My mongrel > processes started at 33MB and grew into 60-70MB while the Ruby > processes under LS stayed at 33MB. And we are talking under sets of > 100K requests on 5/10/50 concurrent requests. For me there is no > discussion now, LS all the way. > > Hope it helps, > > > Adrian Madrid > > > On 7/12/07, Ronald Valente <rawn027-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Do you have any pointers on setting this up? I have a FreeBSD server > > which I am quite fluent with. Not so much with apache or mongrel. > > > > Regards, > > Ron > > > > > > On Jul 12, 2007, at 9:35 PM, Chris Hall wrote: > > > > > > > > we use apache + mongrel at work. easy setup and we have never had a > > > problem. no experience with litespeed. > > > > > > good luck in your decision. > > > > > > On 7/12/07, Ronald Valente <rawn027-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> > > >> I am looking to setup a "test deployment" server for rails and I was > > >> wondering everyone input on which is a good solution to work on. > > >> > > >> According to litespeed using only their server with ruby-lsapi is the > > >> ONLY way to go :-P > > >> > > >> I would just like some realworld experience. > > >> > > >> Thanks! > > >> > > >>> > > >> > > > > > > > > > > > > > > > > > > > -- > Adrian Esteban Madrid > > > >-- Richard J Hancock Developer/System Administrator --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Defiantly do not do FCGI. -Ron On Jul 13, 2007, at 8:09 AM, Richard Hancock wrote:> How well did the Apache + Mongrel do? I have a similar situation > as the OP but I have less options at this time to experiment with. > The only 2 I really have right now is Apache + Mongrel or Apache + > FCGI. > > TIA, > Richard > > On 7/13/07, Adrian Madrid <aemadrid-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Ron, > > I run multiple environments (apache + mongrels, apache + litespeed, > litespeed only) and I can''t tell you nothing beats litespeed in how > easy it is to setup and how fast and stable it is. Recently I > benchmarked one of my apps both with mongrel, mongrel + evented and > litespeed and LS was not only faster but required less RAM. My mongrel > processes started at 33MB and grew into 60-70MB while the Ruby > processes under LS stayed at 33MB. And we are talking under sets of > 100K requests on 5/10/50 concurrent requests. For me there is no > discussion now, LS all the way. > > Hope it helps, > > > Adrian Madrid > > > On 7/12/07, Ronald Valente < rawn027-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Do you have any pointers on setting this up? I have a FreeBSD server > > which I am quite fluent with. Not so much with apache or mongrel. > > > > Regards, > > Ron > > > > > > On Jul 12, 2007, at 9:35 PM, Chris Hall wrote: > > > > > > > > we use apache + mongrel at work. easy setup and we have never > had a > > > problem. no experience with litespeed. > > > > > > good luck in your decision. > > > > > > On 7/12/07, Ronald Valente <rawn027-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> > > >> I am looking to setup a "test deployment" server for rails and > I was > > >> wondering everyone input on which is a good solution to work on. > > >> > > >> According to litespeed using only their server with ruby-lsapi > is the > > >> ONLY way to go :-P > > >> > > >> I would just like some realworld experience. > > >> > > >> Thanks! > > >> > > >>> > > >> > > > > > > > > > > > > > > > > > > > -- > Adrian Esteban Madrid > > > > > > > -- > Richard J Hancock > Developer/System Administrator > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I was playing around with litespeed last night for the first time and was impressed. It''s main advantage IMO over the typical http server -> mongrel cluster -> rails setup is that it has fewer moving parts. A mongrel setup typically has something like monit running also. So far it''s my favorite, and I''ve tried pretty much everything, including jruby on rails and mongrels running under smf in solaris behind a hardware load balancer (which is my second favorite). Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I can second litespeed. It''s pretty nice, just be sure to give the docs a good read to understand their GUI and stuff. It''s not hard, but the docs will help give you a good understanding of how it works. One nice thing about litespeed is that it can spawn/kill off the lsapi processes based on load. Which is nice for my little server with lots of rails apps, but very little traffic (ie, me and my family usually). I''ve used mongrel too and it''s very nice as well, but the ram is used all the time regardless of whether or not you''re getting any traffic. On Thu, 12 Jul 2007, Adrian Madrid wrote:> > Ron, > > I run multiple environments (apache + mongrels, apache + litespeed, > litespeed only) and I can''t tell you nothing beats litespeed in how > easy it is to setup and how fast and stable it is. Recently I > benchmarked one of my apps both with mongrel, mongrel + evented and > litespeed and LS was not only faster but required less RAM. My mongrel > processes started at 33MB and grew into 60-70MB while the Ruby > processes under LS stayed at 33MB. And we are talking under sets of > 100K requests on 5/10/50 concurrent requests. For me there is no > discussion now, LS all the way. > > Hope it helps, > > > Adrian Madrid > > > On 7/12/07, Ronald Valente <rawn027-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Do you have any pointers on setting this up? I have a FreeBSD server >> which I am quite fluent with. Not so much with apache or mongrel. >> >> Regards, >> Ron >> >> >> On Jul 12, 2007, at 9:35 PM, Chris Hall wrote: >> >>> >>> we use apache + mongrel at work. easy setup and we have never had a >>> problem. no experience with litespeed. >>> >>> good luck in your decision. >>> >>> On 7/12/07, Ronald Valente <rawn027-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>> I am looking to setup a "test deployment" server for rails and I was >>>> wondering everyone input on which is a good solution to work on. >>>> >>>> According to litespeed using only their server with ruby-lsapi is the >>>> ONLY way to go :-P >>>> >>>> I would just like some realworld experience. >>>> >>>> Thanks! >>>> >>>>> >>>> >>> >>>> >> >> >>> >> > > > -- > Adrian Esteban Madrid > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---