Hi, I have a few simple lists that I''m displaying all over my site, as paginated partials. Sometimes a given list shows 5 items, sometimes 10, sometimes 20, depending on what page is being displayed. Sometimes a list is sorted by one criterion, sometimes by another. So, being a newbie, I''ve ended up with many different actions to display and to paginate each partial. Lots and lots of actions. What I''d really like is one pagination action, and one display action, per partial, or maybe just one action per partial. How is this done? It''s very cool how I can instantiate an object, in list context, inside an action, then pick up that object in a partial to display and / or paginate the partial, with just a few lines of code, but it might be far easier to just have one or two actions, with a bunch of settings for list size and sorting, to display each partial. Any hints? Charlie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, I have a few simple lists that I''m displaying all over my site, as paginated partials. Sometimes a given list shows 5 items, sometimes 10, sometimes 20, depending on what page is being displayed. Sometimes a list is sorted by one criterion, sometimes by another. So, being a newbie, I''ve ended up with many different actions to display and to paginate each partial. Lots and lots of actions. What I''d really like is one pagination action, and one display action, per partial, or maybe just one action per partial for both. How is this done? It''s very cool how I can instantiate an object, in list context, inside an action, then pick up that object in a partial to display and / or paginate the partial, with just a few lines of code, but it might be far easier to just have one or two actions, with a bunch of settings for list size and sorting, to display each partial. Any ideas? Charlie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If it were me, I would write function in application.rb that would do the dirty work, then have each controller call that function to populate the needed instance variable. eg: class ApplicationController < ActionController::Base def WidgetPagnation(amount,offset,order) Widget.find(:all, :limit=>number, :offset=>offset, :order=>order) end end You may need to add additional constraints that find, and will need to deal with the edge cases where the search is empty, or returns less then the requested number of results. I would do that in display logic for the partial, but web design purists might want it in the controller instead. JFMiller charlie caroff wrote:> Hi, > > I have a few simple lists that I''m displaying all over my site, as > paginated partials. > > Sometimes a given list shows 5 items, sometimes 10, sometimes 20, > depending on what page is being displayed. Sometimes a list is sorted > by one criterion, sometimes by another. > > So, being a newbie, I''ve ended up with many different actions to > display and to paginate each partial. Lots and lots of actions. > > What I''d really like is one pagination action, and one display action, > per partial, or maybe just one action per partial for both. How is > this done? > It''s very cool how I can instantiate an object, in list context, > inside an action, then pick up that object in a partial to display > and / or paginate the partial, with just a few lines of code, but it > might be far easier to just have one or two actions, with a bunch of > settings for list size and sorting, to display each partial. > > Any ideas? > > Charlie-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---