As for some technical ways to do it... go look at ActiveScaffold and see how they handle it.
For me, I have a combination of URL parameters and session values that get passed around. The session values are so some things will stay no matter what (like pagination) and the parameters are for one-time adjustments (like moving to other pages). For example, if I have a model Widgets with a widgets controller, I might have a URL like: http://localhost:3000/widgets?page=1&per_page=25&sort=updated_at&sort_direction=ASC Then I have a before_filter that builds the @widgets collection using WillPaginate and some custom sorting code. I can change the "per_page" value and it is stored in a session variable. But the "page" and "sort" and "sort_direction" are only stored in the params hash. So if I go to some other page then come back to: http://localhost:3000/widgets/ without any params, it will still be 25 records per page, but by default on page 1 with the default sort and default direction. I hope that helps you along. I suspect there may be some good plugins or gems for handling pagination and sorting well. I started with WillPaginate and then added in the sorting code myself. At least for me, it works and works well. -Danimal On Sep 8, 12:43 pm, Matt Harrison <[EMAIL PROTECTED]> wrote: > Matt Harrison wrote: > > Hi all, > > > I've got a list of machines with columns like so: > > > Hostname, Operating System, Location > > > I have setup pagination with paginating_find and that works nicely. I > > have also setup column sorting with my own little helper and > > controller code. Because I wrote the helper myself I have got it to > > preserve the page parameter when changing sort mode. > > > So when you move to a certain page and do a sort, the page is kept in > > the same place. However, if I sort a column and then change to a > > different page, the sorting reverts to the default which makes > > changing the page useless a lot of the time. > > > What is the preferred method to combine column sorting and pagination > > easily? This must be a fairly common exercise but I can't get my head > > round how to do it. > > > Any help would be appreciated. > > Can't believe no-one has any ideas about this, maybe it just got buried > under all the other mail. > > Grateful someone could take a sec to help me :) > > Thanks > > Matt --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

