Sha256: 75a66110cc6a94443a5dc27bec7855bb5ff6ddf4107d60e52616336d5679f787

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

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

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

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

  def show
  end

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

  def edit
  end

  def create
    @admin_user = Admin::User.new(admin_user_params)

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

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

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
administration-zero-0.0.12 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-0.0.11 lib/generators/admin/install/templates/controllers/admin/users_controller.rb
administration-zero-0.0.10 lib/generators/admin/install/templates/controllers/admin/users_controller.rb