Sha256: c4969de259ebd67316c5deb4bcbf50edc143aaceea3994d722ee603df09e6ac0

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

class Backend::AdminsController < BackendController
  before_action :find_admin, only: [:show, :edit, :update, :destroy]
  before_action -> { breadcrumb.add t('b.admins'), backend_admins_path }

  def index
    @admins = Admin.all
  end

  def show
    redirect_to edit_backend_admin_path(@admin)
  end

  def new
    @admin = Admin.new
  end

  def create
    @admin = Admin.new allowed_params

    if @admin.save
      redirect_to backend_admins_path, notice: translate_notice(:added, :admin)
    else
      render :new
    end
  end

  def update
    if @admin.update_attributes allowed_params
      redirect_to backend_admins_path, notice: translate_notice(:changes_saved)
    else
      render :edit
    end
  end

  def destroy
    @admin.destroy
    redirect_to backend_admins_path, notice: translate_notice(:deleted, :admin)
  end

  private

  def find_admin
    @admin = Admin.find params[:id]
  end

  def allowed_params
    params[:admin].permit(
      :first_name, :last_name, :email, :password, :password_confirmation
    )
  end

  def password_required?
    @admin.new_record?
  end
  helper_method :password_required?
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
udongo-2.0.4 app/controllers/backend/admins_controller.rb
udongo-2.0.3 app/controllers/backend/admins_controller.rb
udongo-2.0.2 app/controllers/backend/admins_controller.rb
udongo-2.0.1 app/controllers/backend/admins_controller.rb
udongo-2.0.0 app/controllers/backend/admins_controller.rb
udongo-1.0.4 app/controllers/backend/admins_controller.rb