Help with partials / pagination strategy

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

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

JF, Thanks very much for your post –

Charlie

On Aug 19, 9:18 pm, John M. [email protected]