diff options
| author | mo khan <mo@mokhan.ca> | 2014-02-20 18:45:09 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-02-20 18:45:09 -0700 |
| commit | 5beba5ac1bac65d99eac14d55ee89d70254b58d3 (patch) | |
| tree | cc25cc8e1053d89e577f66995f1529fc0ca8775f /app/controllers/v1 | |
| parent | ab6a0801874f7bd6590f6e57ee76cd2b74c30618 (diff) | |
allow clients to specify the number of items per page.
Diffstat (limited to 'app/controllers/v1')
| -rw-r--r-- | app/controllers/v1/licenses_controller.rb | 5 |
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 |
