# class UsersController

### Public Instance Methods

create() click to toggle source

    POST /users
    POST /users.json

START:create

    # File app/controllers/users_controller.rb, line 31
      def create
        @user = User.new(user_params)

        respond_to do |format|
          if @user.save
            format.html { redirect_to users_url,
              notice: "User #{@user.name} was successfully created." }
            format.json { render action: 'show',
              status: :created, location: @user }
          else
            format.html { render action: 'new' }
            format.json { render json: @user.errors,
              status: :unprocessable_entity }
          end
        end
      end

destroy() click to toggle source

    DELETE /users/1
    DELETE /users/1.json

START:delete_user

    # File app/controllers/users_controller.rb, line 74
    def destroy
      begin
        @user.destroy
        flash[:notice] = "User #{@user.name} deleted"
      rescue Exception => e
        flash[:notice] = e.message
      end
      respond_to do |format|
        format.html { redirect_to users_url }
        format.json { head :no_content }
      end

    end

edit() click to toggle source

GET /users/1/edit

    # File app/controllers/users_controller.rb, line 25
    def edit
    end

index() click to toggle source

    GET /users
    GET /users.json

START:index

    # File app/controllers/users_controller.rb, line 7
      def index
        @users = User.order(:name)
      end

new() click to toggle source

GET /users/new

    # File app/controllers/users_controller.rb, line 20
    def new
      @user = User.new
    end

show() click to toggle source

GET /users/1 GET /users/1.json

    # File app/controllers/users_controller.rb, line 16
    def show
    end

update() click to toggle source

    PATCH/PUT /users/1
    PATCH/PUT /users/1.json

START:update

    # File app/controllers/users_controller.rb, line 54
      def update
        respond_to do |format|
          if @user.update(user_params)
            format.html { redirect_to users_url,
              notice: "User #{@user.name} was successfully updated." }
            format.json { head :no_content }
          else
            format.html { render action: 'edit' }
            format.json { render json: @user.errors,
              status: :unprocessable_entity }
          end
        end
      end