Skip to content

Commit

Permalink
Add per_page option
Browse files Browse the repository at this point in the history
git-svn-id: svn://errtheblog.com/svn/plugins/will_paginate@100 1eaa51fe-a21a-0410-9c2e-ae7a00a434c4
  • Loading branch information
pj committed Feb 7, 2007
1 parent a4ebc22 commit 31dfabb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ WillPaginate

Ruby port by: PJ Hyett
Original PHP source: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php
Contributors: K. Adam Christensen, Chris Wanstrath
Contributors: K. Adam Christensen, Chris Wanstrath, Dr. Nic Williams

Example usage:

Expand Down
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'will_paginate'
require 'finder'
ActionView::Base.send(:include, WillPaginate)
ActiveRecord::Base.send(:include, WillPaginate::Finder)
ActiveRecord::Base.send(:include, Finder)
4 changes: 3 additions & 1 deletion lib/finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ def method_missing_with_will_paginate(method_id, *args, &block)
options = args.last.is_a?(Hash) ? args.pop : {}
page = options[:page].to_i.zero? ? 1 : options[:page].to_i
options.delete(:page)
limit_per_page = options[:per_page] || per_page
options.delete(:per_page)
args << options

with_scope :find => { :offset => (page - 1) * per_page, :limit => per_page } do
with_scope :find => { :offset => (page - 1) * limit_per_page, :limit => limit_per_page } do
[send(method_id.to_s.sub(/^paginate/, 'find'), *args), page]
end
end
Expand Down

0 comments on commit 31dfabb

Please sign in to comment.