Implement state search with new model

This commit is contained in:
2025-10-08 08:22:04 -07:00
parent 7bf4073bd2
commit 55f712d043
4 changed files with 15 additions and 1 deletions

View File

@@ -5,7 +5,7 @@ module Api::V1
def index
parks = Park.all
if params[:state].present?
parks = parks.where("states like '%' || ? || '%'", params[:state])
parks = parks.joins(:states).where(parks_by_states: { state: params[:state] })
end
render json: {
total: parks.count,