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 ? thanks, sk
on 2006-12-22 04:06
on 2006-12-22 04:56
> 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.
on 2006-12-22 05:18
right, sorry, i will use the rails list for this kinda thing. btw, the @group.sites thing did work. Thanks. sk