Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: problem with pagination, rails
Giles Bowkett
12/22/2006 2:56:00 AM
> lo there all,
> i am having some trouble getting pagination going the way i need for a rails
> app.
>
> the controller looks like this
>
> def summary
> @site_pages, @sites = paginate(:sites,
> :conditions => ['group_id = ?', @group.id],
> :order => 'site_name' )
> end
>
>
> the problem is that it is listing every site, not just those belonging to group
>
> anyone know what i can do about this ?
I hate to say this but the best thing is to take this question to the
Rails list; the Ruby list is more about Ruby in general than Rails
specifically. What you're dealing with there is definitely a Rails
question.
That being said, my guess is that you can probably solve it by doing
paginate(@group.sites, :order => "site_name")
Since you've already got the group, and the sites appear to belong to
it. **If** I'm right then you'll also make your app more efficient by
doing this, since the way you have it now looks as if it involves an
additional SQL call.
Alternatively, if the @group.sites thing doesn't work and it looks as
if you need to do a SQL call to do any pagination, don't, just search
for "paginate_collection" and "canadaduane" on Google. Add the
paginate_collection code to your application controller and you'll be
a happy camper.
--
Giles Bowkett
http://www.gilesg...
http://gilesbowkett.bl...
http://gilesgoatboy.bl...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: problem with pagination, rails
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password