21 lines
352 B
Ruby
21 lines
352 B
Ruby
class Api::V1::ParksController < ApplicationController
|
|
DEFAULT_PAGE_SIZE = 10
|
|
|
|
def index
|
|
parks = Park
|
|
.limit(per_page)
|
|
.offset((page - 1) * per_page)
|
|
render json: parks
|
|
end
|
|
|
|
private
|
|
|
|
def per_page
|
|
(params[:per_page].presence || DEFAULT_PAGE_SIZE).to_i
|
|
end
|
|
|
|
def page
|
|
(params[:page].presence || 1).to_i
|
|
end
|
|
end
|