hi,
Once I get the opportunity to again work with Rails (that should be
soon), I''ll look to the possibility to use this pagination helper in
the tablehelper (which also has pagination code). I''ll also make the
tablehelper more AR friendly. The tablehelper is available at
http://tablehelper.rubyforge.org , if any of you is interested
Raph
On Sun, 26 Dec 2004 22:12:27 -0500, Sam Stephenson
<sstephenson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi guys,
>
> I created Pagination Helper several months ago as a quick solution to
> the pagination problem. You might be familiar with it. You can see the
> old version on the Rails wiki[1].
>
> Despite the insistence of several people that I either gemify it or
> submit it for inclusion to Rails, I refused. I wasn''t confident
that
> the API was right for Rails, and I wanted to encourage people to
> modify it because I felt I''d probably missed useful things. I
posted
> the source code to the wiki and waited for people to submit their
> changes, but it remained fairly stagnant.
>
> In the past few weeks, however, there''s been a lot of talk
surrounding
> Pagination Helper, including
> some changes on the wiki to make it work with newer versions of Rails,
> and an entry about it on _why''s new RedHanded Ruby blog[2]. This,
> along with Rails'' ever-expanding domain language magic, inspired
me to
> update it[3] and make it more "Rails-ish."
>
> Pagination Helper is fully documented, but I''ll go over the new
> features here. There''s two new "paginate" methods which
add to the
> Rails domain language. From the docs:
>
> | class PersonController < ApplicationController
> | helper :pagination
> | model :person
> |
> | paginate :people, :order_by => ''last_name,
first_name'',
> | :per_page => 20
> |
> | # ...
> | end
>
> This automatically creates a before_filter. Each action in this
> controller now has access to a @people variable filled with the model
> objects for the current page (at most 20, and ordered by last name and
> first name), and a @person_pages Paginator instance. There are also
> options for specifying the page CGI parameter, the conditions for
> Model#find_all and Model#count, the model''s class name, and the
> actions for which pagination magic happens.
>
> | def list
> | @person_pages, @people > | paginate :people, :order_by =>
''last_name, first_name''
> | end
>
> This is like the previous example, but explicitly creates
> @person_pages and @people in a single action, and uses the default of
> 10 items per page.
>
> You can still use Paginator and friends, just like in the old version.
> In fact, not much has changed there. There''s a new
> Paginator#basic_html method which gives you a nice, plain HTML
> rendering of page links, and Page#to_link now merges in an optional
> hash for specifying additional link parameters.
>
> I''d like those of you who are using the old Pagination Helper to
try
> out this new version and let me know what you think it needs before it
> can be included in Rails proper. When I feel it''s fit for
submission,
> I''ll make a trac ticket. I think this would be really nice to
include
> in Rails 1.0.
>
> --
> Sam
>
> [1] http://www.rubyonrails.org/show/PaginatorHelper
> [2] http://redhanded.hobix.com/inspect/aPaginationHelperForRails.html
> [3] http://conio.net/code/pagination_helper.rb
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>