Sha256: ecab5c7df235edcf0884b98f733262baac30b245eda3754387b744c3719017ad

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

# generado con pg_rails

module Admin
  class UsersController < AdminController
    before_action { @clase_modelo = User }

    before_action(only: :index) { authorize User }

    before_action only: %i[update] do
      params[:user].delete(:password) if params[:user][:password].blank?
    end

    before_action :set_instancia_modelo, only: %i[new create show edit update destroy]

    add_breadcrumb User.nombre_plural, :admin_users_path

    def create
      @user.skip_confirmation!
      pg_respond_create
    end

    def update
      @user.skip_reconfirmation!
      pg_respond_update
    end

    skip_before_action :authenticate_user!, only: [:login_as]

    # :nocov:
    def login_as
      if current_user&.developer? || Rails.env.development?
        usuario = User.find(params[:id])
        sign_in(:user, usuario)
      end
      redirect_to '/'
    end
    # :nocov:

    private

    def atributos_permitidos
      %i[email nombre apellido password developer]
    end

    def atributos_para_buscar
      %i[email nombre apellido developer]
    end

    def atributos_para_listar
      %i[email nombre apellido developer]
    end

    def atributos_para_mostrar
      %i[email nombre apellido developer]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pg_rails-7.0.8.pre.alpha.13 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.12 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.11 pg_engine/app/controllers/admin/users_controller.rb
pg_rails-7.0.8.pre.alpha.10 pg_engine/app/controllers/admin/users_controller.rb