Add api/v1 base controller

This commit is contained in:
2025-10-08 00:46:18 -07:00
parent 832164ead2
commit adcaf46d33
2 changed files with 19 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
module Api::V1::Parks module Api::V1
class BaseController < ApplicationController class Parks::BaseController < BaseController
before_action :set_park before_action :set_park
private private

View File

@@ -1,5 +1,5 @@
class Api::V1::ParksController < ApplicationController module Api::V1
DEFAULT_PAGE_SIZE = 10 class ParksController < BaseController
before_action :set_park, only: :show before_action :set_park, only: :show
def index def index
@@ -16,16 +16,9 @@ class Api::V1::ParksController < ApplicationController
private 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 def set_park
@park = Park.find_by(code: params[:code]) @park = Park.find_by(code: params[:code])
head :not_found unless @park.present? head :not_found unless @park.present?
end end
end end
end