Forum: Ruby on Rails Newbies: Read this before asking about pagination

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0900e6a4828bd989f96427082c6c74ca?d=identicon&s=25 Mike Garey (random52k)
on 2007-07-12 23:44
(Received via mailing list)
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/br...

http://groups.google.com/group/rubyonrails-talk/br...

http://groups.google.com/group/rubyonrails-talk/br...
9dfe8c734b0f9b37a4e218425c0a2138?d=identicon&s=25 gene.tani@gmail.com (Guest)
on 2007-07-13 01:02
(Received via mailing list)
On Jul 12, 2:43 pm, "Mike Garey" <random...@gmail.com> wrote:
> # paginate the list:
>
>
>
> http://groups.google.com/group/rubyonrails-talk/br......

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
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-07-13 01:23
(Received via mailing list)
another great alternative is the paginator gem.

http://paginator.rubyforge.org/
A3c73a768477c8f93dd48d9611376046?d=identicon&s=25 Ron Mr. (rawn027)
on 2007-07-13 01:49
(Received via mailing list)
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!
A3c73a768477c8f93dd48d9611376046?d=identicon&s=25 Ron Mr. (rawn027)
on 2007-07-13 03:16
(Received via mailing list)
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!
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-07-13 03:36
(Received via mailing list)
we use apache + mongrel at work.  easy setup and we have never had a
problem.  no experience with litespeed.

good luck in your decision.
A3c73a768477c8f93dd48d9611376046?d=identicon&s=25 Ron Mr. (rawn027)
on 2007-07-13 03:55
(Received via mailing list)
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
67d3880bbfaafdb2a2108b7c9a64df47?d=identicon&s=25 Adrian Madrid (Guest)
on 2007-07-13 07:22
(Received via mailing list)
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@gmail.com> wrote:
> >
> >> According to litespeed using only their server with ruby-lsapi is the
>
>
> >
>


--
Adrian Esteban Madrid
2dcb81d519c3707c043f28b3b6fe4f28?d=identicon&s=25 Richard Hancock (Guest)
on 2007-07-13 14:10
(Received via mailing list)
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@gmail.com> wrote:
> processes under LS stayed at 33MB. And we are talking under sets of
> >
> > > we use apache + mongrel at work.  easy setup and we have never had a
> > >> ONLY way to go :-P
> >
> > >
> >
>
>
> --
> Adrian Esteban Madrid
>
> >
>


--
Richard J Hancock
Developer/System Administrator
2f9a03aa0fcfe945229cb6126eda2cb2?d=identicon&s=25 Philip Hallstrom (Guest)
on 2007-07-13 19:52
(Received via mailing list)
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.
F48118fe74b0c7f6fd82a0ee422fa34e?d=identicon&s=25 snacktime (Guest)
on 2007-07-13 20:01
(Received via mailing list)
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
A3c73a768477c8f93dd48d9611376046?d=identicon&s=25 Ron Mr. (rawn027)
on 2007-07-13 22:34
(Received via mailing list)
Defiantly do not do FCGI.

-Ron
This topic is locked and can not be replied to.