SHARE
TWEET

Untitled

a guest Sep 16th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class UsersController < ApplicationController
  2.  
  3.   before_action :user_params, :only [:create, :update]
  4.   before_action :user_find, :only [:shoe, :edit, :update, :destroy]
  5.   after_action :slack_notify, :only [:create, :update, :destroy]
  6.  
  7.   def index
  8.     @users = User.all
  9.   end
  10.  
  11.   def show
  12.   end
  13.  
  14.   def new
  15.     @user = User.new
  16.   end
  17.  
  18.   def edit
  19.   end
  20.  
  21.   def create
  22.     respond_to do |format|
  23.       if @user.save
  24.         format.html { redirect_to @user, notice: 'User was successfully created.' }
  25.         format.json { render :show, status: :created, location: @user }
  26.       else
  27.         format.html { render :new }
  28.         format.json { render json: @user.errors, status: :unprocessable_entity }
  29.       end
  30.     end
  31.   end
  32.  
  33.   def update
  34.     respond_to do |format|
  35.       if @user.update(user_params)
  36.         format.html { redirect_to @user, notice: 'User was successfully updated.' }
  37.         format.json { render :show, status: :ok, location: @user }
  38.       else
  39.         format.html { render :edit }
  40.         format.json { render json: @user.errors, status: :unprocessable_entity }
  41.       end
  42.     end
  43.   end
  44.  
  45.   def destroy
  46.     @user.destroy
  47.     respond_to do |format|
  48.       format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
  49.       format.json { head :no_content }
  50.     end
  51.   end
  52.  
  53.   private
  54.     def user_params
  55.       params.require(:user).permit(:username, :email)
  56.     end
  57. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top