Sha256: 69f4b42bbb4429a9aee5a391503befcae1c159a2465cdb29d1a254dc852c53c1

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

ActiveAdmin.register User do
  decorate_with UserDecorator
  permit_params :email, :password, :password_confirmation, :confirmed_at, profiles: []

  index do
    selectable_column
    id_column
    column :email
    column :current_sign_in_at
    column :created_at
    actions
  end
  filter :email

  form do |f|
    f.inputs do
      if params[:change_password]
        f.input :password
      else
        f.input :email
        f.input :password unless f.object.persisted?
        f.input :profiles, as: :select
      end
    end
    f.actions
  end

  before_update(&:skip_reconfirmation!)
  after_build do |user|
    user.skip_confirmation! if action_name == 'create'
  end

  member_action :discard, method: :put do
    resource.discard!
    redirect_to resource_path, notice: 'Discarded!'
  end

  member_action :restore, method: :put do
    resource.undiscard!
    redirect_to resource_path, notice: 'Restored!'
  end

  action_item :view, only: :show do
    link_to 'Discard', discard_active_admin_user_path(resource), method: :put if resource.kept?
  end

  action_item :view, only: :show do
    link_to 'Restore', restore_active_admin_user_path(resource), method: :put if resource.discarded?
  end

  action_item :view, only: :show do
    link_to 'Cambiar contraseƱa', edit_active_admin_user_path(resource, change_password: true)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pg_rails-7.0.6 pg_engine/lib/templates/activeadmin/users.rb
pg_rails-7.0.5 pg_engine/lib/templates/activeadmin/users.rb
pg_rails-7.0.4 pg_engine/lib/templates/activeadmin/users.rb
pg_rails-7.0.3 pg_engine/lib/templates/activeadmin/users.rb
pg_rails-7.0.2 pg_engine/lib/templates/activeadmin/users.rb