Show Users
Add the standard HTTP method, GET, for the User model in the API.
We'll cover the following...
Define the show action
We will define the show action by simply adding the action to our controllers in app/controllers/api/v1/users_controller.rb. The code for the show function is as follows:
class Api::V1::UsersController < ApplicationController# GET /users/1def showrender json: User.find(params[:id])endend
Add test
There are two things we want to test for an API:
- The JSON structure returned by the server.
- The HTTP