Created
June 23, 2010 02:47
-
-
Save ghiden/449422 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# using Paginator with MongoMapper | |
# index action in a controller | |
def index | |
@pager = Paginator.new(User.count, 20) do |offset, per_page| | |
User.all(:offset => offset, :limit => per_page, :order => "created_at DESC") | |
end | |
@users = @pager.page(params[:page]) | |
respond_to do |format| | |
format.html # index.html.erb | |
format.xml { render :xml => @users } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This should show page numbers, 1 2 3 ... with hyperlinks --> | |
<% ([email protected]_of_pages).to_a.each do |p| %> | |
<%= p == @users.number ? p : link_to(p, users_path(:page => p)) %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment