summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-20 18:45:09 -0700
committermo khan <mo@mokhan.ca>2014-02-20 18:45:09 -0700
commit5beba5ac1bac65d99eac14d55ee89d70254b58d3 (patch)
treecc25cc8e1053d89e577f66995f1529fc0ca8775f /app/controllers
parentab6a0801874f7bd6590f6e57ee76cd2b74c30618 (diff)
allow clients to specify the number of items per page.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/v1/licenses_controller.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/controllers/v1/licenses_controller.rb b/app/controllers/v1/licenses_controller.rb
index e919663..45a6489 100644
--- a/app/controllers/v1/licenses_controller.rb
+++ b/app/controllers/v1/licenses_controller.rb
@@ -3,8 +3,9 @@ class V1::LicensesController < ApplicationController
DEFAULT_PAGE = 1
def index
- page = params[:page].to_i || DEFAULT_PAGE
- @licenses = License.most_recent(page, PER_PAGE)
+ page = params[:page].present? ? params[:page].to_i : DEFAULT_PAGE
+ per_page = params[:per_page].present? ? params[:per_page].to_i : PER_PAGE
+ @licenses = License.most_recent(page, per_page)
render nothing: true
end
end