Skip to content

dhyegocalota/active_admin-form_errors

Repository files navigation

ActiveAdmin Form Errors

Pretty form errors by default in your ActiveAdmin.

Installation

1. Import gem

gem 'active_admin-form_errors'

2. Import stylesheets (change app/assets/stylesheets/active_admin.scss)

@import 'active_admin/form_errors';

Options

Disable it in a specific resource

ActiveAdmin.register User do
  config.form_errors = false
end

Disable by default at all resources (change config/initializers/active_admin.rb)

ActiveAdmin.setup do
  config.form_errors = false
end

Show only specific errors

ActiveAdmin.register User do
  config.form_errors = lambda do
    if current_user.admin?
      resource.errors.keys
    else
      [:name, :email]
    end
  end
end

Change the color base

$form-errors-color: red; // must be before the import

@import 'active_admin/form_errors';

Maintainer

Dhyego Fernando