Sha256: 686e70b4e478f3ee4a9164ab4b9547f584c3e09f3afed1095a9e41d3888e1a52
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
class UsersController < ApplicationController before_action :set_user, only: [:show, :update, :destroy] # GET /users # GET /users.json def index @users = User.all render json: @users end # GET /users/1 # GET /users/1.json def show render json: @user end # POST /users # POST /users.json def create @user = User.new(user_params) if @user.save render json: @user, status: :created, location: @user else render json: @user.errors, status: :unprocessable_entity end end # PATCH/PUT /users/1 # PATCH/PUT /users/1.json def update @user = User.find(params[:id]) if @user.update(user_params) head :no_content else render json: @user.errors, status: :unprocessable_entity end end # DELETE /users/1 # DELETE /users/1.json def destroy @user.destroy head :no_content end private def set_user @user = User.find(params[:id]) end def user_params params.require(:user).permit(:email, :first_name, :last_name) end end
Version data entries
5 entries across 4 versions & 1 rubygems