Add api/v1 base controller
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
module Api::V1::Parks
|
||||
class BaseController < ApplicationController
|
||||
module Api::V1
|
||||
class Parks::BaseController < BaseController
|
||||
before_action :set_park
|
||||
|
||||
private
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Api::V1::ParksController < ApplicationController
|
||||
DEFAULT_PAGE_SIZE = 10
|
||||
module Api::V1
|
||||
class ParksController < BaseController
|
||||
before_action :set_park, only: :show
|
||||
|
||||
def index
|
||||
@@ -16,16 +16,9 @@ class Api::V1::ParksController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def per_page
|
||||
(params[:per_page].presence || DEFAULT_PAGE_SIZE).to_i
|
||||
end
|
||||
|
||||
def page
|
||||
(params[:page].presence || 1).to_i
|
||||
end
|
||||
|
||||
def set_park
|
||||
@park = Park.find_by(code: params[:code])
|
||||
head :not_found unless @park.present?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user