blob: c62c78b3da0743c418b68435fad33d98f1c39529 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
class V1::LicensesController < ApplicationController
PER_PAGE = 10
DEFAULT_PAGE = 1
before_filter :prepare_pagination
def index
@licenses = License.most_recent(page: @page, per_page: @per_page)
render json: @licenses
end
def show
@license = License.find(params[:id])
render json: @license
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
|