Add documentation for passing nil to #per

This commit is contained in:
Bryan Ricker 2012-11-03 13:08:09 -07:00
parent 949f345a50
commit 3b293cfca6
1 changed files with 5 additions and 1 deletions

View File

@ -62,7 +62,11 @@ Then bundle:
To show a lot more users per each page (change the +per_page+ value) To show a lot more users per each page (change the +per_page+ value)
User.page(7).per(50) User.page(7).per(50)
Note that the +per+ scope is not directly defined on the models but is just a method defined on the page scope. This is absolutely reasonable because you will never actually use +per_page+ without specifying the +page+ number. Note that the +per+ scope is not directly defined on the models but is just a method defined on the page scope. This is absolutely reasonable because you will never actually use +per_page+ without specifying the +page+ number.
If you would like to specify "no limit" while still using the +per+ scope, you can pass +nil+:
User.count # => 1000
User.page(1).per(nil).size # => 1000
* the +padding+ scope * the +padding+ scope
Occasionally you need to padding a number of records that is not a multiple of the page size. Occasionally you need to padding a number of records that is not a multiple of the page size.