Sha256: 13e30fc047caca950d2dd36d2ee5480d044b68e008726b9fcf87ad18f87f7e28

Contents?: true

Size: 1.09 KB

Versions: 12

Compression:

Stored size: 1.09 KB

Contents

class Admin::UsersController < Admin::BaseController
  before_action :set_user, only: %i[ show edit update destroy ]

  def index
    @search = Admin::User.all.ransack(params[:q])

    respond_to do |format|
      format.html { @pagy, @users = pagy(@search.result) }
      format.csv  { render csv: @search.result }
    end
  end

  def show
  end

  def new
    @user = Admin::User.new
  end

  def edit
  end

  def create
    @user = Admin::User.new(user_params)

    if @user.save
      redirect_to @user, notice: "User was successfully created."
    else
      render :new, status: :unprocessable_entity
    end
  end

  def update
    if @user.update(user_params)
      redirect_to @user, notice: "User was successfully updated."
    else
      render :edit, status: :unprocessable_entity
    end
  end

  def destroy
    @user.destroy
    redirect_to admin_users_url, notice: "User was successfully destroyed."
  end

  private
    def set_user
      @user = Admin::User.find(params[:id])
    end

    def user_params
      params.require(:admin_user).permit(:email, :password, :password_confirmation)
    end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
administration-zero-1.0.6 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-1.0.5 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-1.0.4 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-1.0.3 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-1.0.2 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-1.0.1 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-1.0.0 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-0.0.18 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-0.0.17 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-0.0.16 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-0.0.15 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-0.0.14 lib/generators/admin/install/templates/controllers/admin/users_controller.rb