Params & Strong Params

One hash, three sources

Every controller action has access to a params hash, and it doesn't care WHERE a value came from β€” Rails merges three different sources into that one hash before your action ever runs:

  • Path params β€” captured from the URL itself by the route: /api/walkers/:id means params[:id] is whatever segment sat where :id was.
  • Query params β€” the ?key=value part of the URL: /api/walkers?city=Austin means params[:city] is "Austin".
  • Body params β€” a JSON object sent in a POST/PATCH request body, parsed automatically into the same hash.

You've already used the first two without naming them: Walker.find(params[:id]) reads a path param, and walkers.in_city(params[:city]) if params[:city].present? (a real line from apps/pawwalk-api) reads a query param straight into the scope you built in module 07.