MΓ³dulo 08 Β· REST & JSON Controllers β LecciΓ³n 1 de 5 Β· ~11 min
render json:
dogpark has been HTML this whole time
Every controller action you've written so far β the scaffolded Walker views back in an earlier module β renders an .html.erb template. A browser asks for /walkers, Rails hands back a full HTML page. That's the ONLY thing a browser can display directly, so it made sense while you were learning Rails' shape.
But PawWalk's real clients are iOS and (later) Android apps. They don't want a page β they want data: a JSON object they can decode into a Walker struct. Rails controllers don't care what format they respond in; render just needs a different argument.