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
class BaseController < ApplicationController
module Api::V1
class Parks::BaseController < BaseController
before_action :set_park
private

View File

@@ -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