respond_to
class UsersController < ApplicationController def show @user = User.find(params[:id]) respond_to do |format| format.html format.json { render json: @user } end end end
参考:
respond_to について調べてみた | DevelopersIO
respond_to – ActionController::MimeResponds | Ruby on Rails API [Official]