summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-20 18:46:48 -0700
committermo khan <mo@mokhan.ca>2014-02-20 18:46:48 -0700
commit4f506a2366115e61c6f0cbb5ae154e2555b9d1ca (patch)
tree720bbb8a1c834ae3966cc96420b17587fcca25fa /app/controllers
parent5beba5ac1bac65d99eac14d55ee89d70254b58d3 (diff)
extract filter to prepare pagination fields.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/v1/licenses_controller.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/v1/licenses_controller.rb b/app/controllers/v1/licenses_controller.rb
index 45a6489..d8c16b6 100644
--- a/app/controllers/v1/licenses_controller.rb
+++ b/app/controllers/v1/licenses_controller.rb
@@ -1,11 +1,17 @@
class V1::LicensesController < ApplicationController
PER_PAGE = 10
DEFAULT_PAGE = 1
+ before_filter :prepare_pagination
def index
- 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)
+ @licenses = License.most_recent(@page, @per_page)
render nothing: true
end
+
+ private
+
+ def prepare_pagination
+ @page = params[:page].present? ? params[:page].to_i : DEFAULT_PAGE
+ @per_page = params[:per_page].present? ? params[:per_page].to_i : PER_PAGE
+ end
end