diff --git a/app/controllers/api/v1/parks_controller.rb b/app/controllers/api/v1/parks_controller.rb index 7dfa682..b1ee732 100644 --- a/app/controllers/api/v1/parks_controller.rb +++ b/app/controllers/api/v1/parks_controller.rb @@ -2,10 +2,11 @@ class Api::V1::ParksController < ApplicationController DEFAULT_PAGE_SIZE = 10 def index - parks = Park - .limit(per_page) - .offset((page - 1) * per_page) - render json: parks + parks = Park.all + if params[:state].present? + parks = parks.where("states like '%' || ? || '%'", params[:state]) + end + render json: parks.limit(per_page).offset((page - 1) * per_page) end private