Sha256: 39ece7f543a83cd6321897d798da3e7fc6baf5334b8dd862c81640acb86df75d

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

class UsersController < ApplicationController
  before_action :set_user, only: [:show, :edit, :update, :destroy]

  # GET /users
  def index
    @users = User.all
  end

  # GET /users/1
  def show
  end

  # GET /users/new
  def new
    @user = User.new
  end

  # GET /users/1/edit
  def edit
  end

  # POST /users
  def create
    @user = User.new(user_params)

    if @user.save
      redirect_to @user, notice: 'User was successfully created.'
    else
      render action: 'new'
    end
  end

  # PATCH/PUT /users/1
  def update
    if @user.update(user_params)
      redirect_to @user, notice: 'User was successfully updated.'
    else
      render action: 'edit'
    end
  end

  # DELETE /users/1
  def destroy
    @user.destroy
    redirect_to users_url, notice: 'User was successfully destroyed.'
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_user
      @user = User.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def user_params
      params.require(:user).permit(:email, :name)
    end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
prosperity-0.0.11 spec/dummy/app/controllers/users_controller.rb
prosperity-0.0.10 spec/dummy/app/controllers/users_controller.rb
prosperity-0.0.9 spec/dummy/app/controllers/users_controller.rb
prosperity-0.0.8 spec/dummy/app/controllers/users_controller.rb
prosperity-0.0.7 spec/dummy/app/controllers/users_controller.rb
prosperity-0.0.6 spec/dummy/app/controllers/users_controller.rb
prosperity-0.0.5 spec/dummy/app/controllers/users_controller.rb
prosperity-0.0.4 spec/dummy/app/controllers/users_controller.rb
prosperity-0.0.3 spec/dummy/app/controllers/users_controller.rb
prosperity-0.0.2 spec/dummy/app/controllers/users_controller.rb
prosperity-0.0.1 spec/dummy/app/controllers/users_controller.rb