Sha256: b777cd2596d861fc3bb92c6a01b685dfcfd0e7b93d21a2543334aca87538e9cd

Contents?: true

Size: 1.13 KB

Versions: 61

Compression:

Stored size: 1.13 KB

Contents

class Backend::AdminsController < Backend::BaseController
  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(
      :locale, :first_name, :last_name, :email, :password, :password_confirmation
    )
  end

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

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
udongo-7.9.0 app/controllers/backend/admins_controller.rb
udongo-7.8.1 app/controllers/backend/admins_controller.rb
udongo-7.8.0 app/controllers/backend/admins_controller.rb
udongo-7.7.2 app/controllers/backend/admins_controller.rb
udongo-7.7.1 app/controllers/backend/admins_controller.rb
udongo-7.7.0 app/controllers/backend/admins_controller.rb
udongo-7.6.2 app/controllers/backend/admins_controller.rb
udongo-7.6.1 app/controllers/backend/admins_controller.rb
udongo-7.6.0 app/controllers/backend/admins_controller.rb
udongo-7.5.1 app/controllers/backend/admins_controller.rb
udongo-7.5.0 app/controllers/backend/admins_controller.rb
udongo-7.4.2 app/controllers/backend/admins_controller.rb
udongo-7.4.1 app/controllers/backend/admins_controller.rb
udongo-7.4.0 app/controllers/backend/admins_controller.rb
udongo-7.3.5 app/controllers/backend/admins_controller.rb
udongo-7.3.4 app/controllers/backend/admins_controller.rb
udongo-7.3.3 app/controllers/backend/admins_controller.rb
udongo-7.3.2 app/controllers/backend/admins_controller.rb
udongo-7.3.1 app/controllers/backend/admins_controller.rb
udongo-7.2.1 app/controllers/backend/admins_controller.rb