Module: RailsAdmin

Extended by:
Config::ConstLoadSuppressor
Defined in:
lib/rails_admin.rb,
lib/rails_admin/config.rb,
lib/rails_admin/engine.rb,
lib/rails_admin/version.rb,
lib/rails_admin/extension.rb,
lib/rails_admin/config/model.rb,
lib/rails_admin/config/fields.rb,
lib/rails_admin/abstract_model.rb,
lib/rails_admin/config/actions.rb,
lib/rails_admin/config/hideable.rb,
lib/rails_admin/config/sections.rb,
lib/generators/rails_admin/utils.rb,
lib/rails_admin/adapters/mongoid.rb,
lib/rails_admin/config/groupable.rb,
lib/rails_admin/config/proxyable.rb,
lib/rails_admin/support/datetime.rb,
lib/rails_admin/config/has_fields.rb,
lib/rails_admin/config/has_groups.rb,
lib/rails_admin/config/lazy_model.rb,
lib/rails_admin/config/actions/new.rb,
lib/rails_admin/config/fields/base.rb,
lib/rails_admin/config/inspectable.rb,
app/helpers/rails_admin/main_helper.rb,
lib/rails_admin/config/actions/base.rb,
lib/rails_admin/config/actions/edit.rb,
lib/rails_admin/config/actions/show.rb,
lib/rails_admin/config/configurable.rb,
lib/rails_admin/config/fields/group.rb,
lib/rails_admin/config/fields/types.rb,
lib/rails_admin/support/hash_helper.rb,
app/helpers/rails_admin/form_builder.rb,
lib/rails_admin/config/actions/index.rb,
lib/rails_admin/config/sections/base.rb,
lib/rails_admin/config/sections/edit.rb,
lib/rails_admin/config/sections/list.rb,
lib/rails_admin/config/sections/show.rb,
lib/rails_admin/adapters/mongoid/bson.rb,
lib/rails_admin/config/actions/delete.rb,
lib/rails_admin/config/actions/export.rb,
lib/rails_admin/config/sections/modal.rb,
lib/rails_admin/support/csv_converter.rb,
lib/rails_admin/adapters/active_record.rb,
lib/rails_admin/config/has_description.rb,
lib/rails_admin/config/proxyable/proxy.rb,
lib/rails_admin/config/sections/create.rb,
lib/rails_admin/config/sections/export.rb,
lib/rails_admin/config/sections/nested.rb,
lib/rails_admin/config/sections/update.rb,
lib/rails_admin/config/actions/dashboard.rb,
lib/rails_admin/config/fields/types/date.rb,
lib/rails_admin/config/fields/types/enum.rb,
lib/rails_admin/config/fields/types/inet.rb,
lib/rails_admin/config/fields/types/json.rb,
lib/rails_admin/config/fields/types/text.rb,
lib/rails_admin/config/fields/types/time.rb,
lib/rails_admin/config/fields/types/uuid.rb,
lib/rails_admin/adapters/mongoid/property.rb,
lib/rails_admin/config/fields/association.rb,
lib/rails_admin/config/fields/types/color.rb,
lib/rails_admin/config/fields/types/float.rb,
app/helpers/rails_admin/application_helper.rb,
lib/rails_admin/adapters/mongoid/extension.rb,
lib/rails_admin/config/actions/bulk_delete.rb,
lib/rails_admin/config/actions/show_in_app.rb,
lib/rails_admin/config/fields/types/citext.rb,
lib/rails_admin/config/fields/types/froala.rb,
lib/rails_admin/config/fields/types/hidden.rb,
lib/rails_admin/config/fields/types/shrine.rb,
lib/rails_admin/config/fields/types/string.rb,
app/controllers/rails_admin/main_controller.rb,
lib/rails_admin/config/actions/history_show.rb,
lib/rails_admin/config/fields/types/boolean.rb,
lib/rails_admin/config/fields/types/decimal.rb,
lib/rails_admin/config/fields/types/integer.rb,
lib/rails_admin/config/fields/types/numeric.rb,
lib/rails_admin/support/es_module_processor.rb,
lib/generators/rails_admin/install_generator.rb,
lib/rails_admin/adapters/mongoid/association.rb,
lib/rails_admin/config/actions/history_index.rb,
lib/rails_admin/config/const_load_suppressor.rb,
lib/rails_admin/config/fields/types/datetime.rb,
lib/rails_admin/config/fields/types/password.rb,
lib/rails_admin/extensions/url_for_extension.rb,
lib/rails_admin/config/fields/types/ck_editor.rb,
lib/rails_admin/config/fields/types/dragonfly.rb,
lib/rails_admin/config/fields/types/paperclip.rb,
lib/rails_admin/config/fields/types/timestamp.rb,
lib/rails_admin/config/fields/types/wysihtml5.rb,
lib/generators/rails_admin/importmap_formatter.rb,
lib/rails_admin/config/fields/types/serialized.rb,
lib/rails_admin/config/fields/types/simple_mde.rb,
lib/rails_admin/adapters/active_record/property.rb,
lib/rails_admin/config/fields/types/action_text.rb,
lib/rails_admin/config/fields/types/carrierwave.rb,
lib/rails_admin/config/fields/types/code_mirror.rb,
lib/rails_admin/config/fields/types/file_upload.rb,
lib/rails_admin/config/fields/types/string_like.rb,
lib/rails_admin/extensions/controller_extension.rb,
lib/rails_admin/adapters/mongoid/object_extension.rb,
lib/rails_admin/support/composite_keys_serializer.rb,
app/controllers/rails_admin/application_controller.rb,
lib/rails_admin/adapters/active_record/association.rb,
lib/rails_admin/config/fields/singular_association.rb,
lib/rails_admin/config/fields/types/active_storage.rb,
lib/rails_admin/config/fields/types/bson_object_id.rb,
lib/rails_admin/config/fields/collection_association.rb,
lib/rails_admin/config/fields/types/active_record_enum.rb,
lib/rails_admin/adapters/active_record/object_extension.rb,
lib/rails_admin/config/fields/types/has_one_association.rb,
lib/rails_admin/extensions/paper_trail/auditing_adapter.rb,
lib/rails_admin/extensions/pundit/authorization_adapter.rb,
lib/rails_admin/config/fields/types/has_many_association.rb,
lib/rails_admin/config/fields/types/multiple_carrierwave.rb,
lib/rails_admin/config/fields/types/multiple_file_upload.rb,
lib/rails_admin/config/fields/types/belongs_to_association.rb,
lib/rails_admin/extensions/cancancan/authorization_adapter.rb,
lib/rails_admin/config/fields/types/multiple_active_storage.rb,
lib/rails_admin/config/fields/types/polymorphic_association.rb,
lib/rails_admin/config/fields/types/has_and_belongs_to_many_association.rb

Defined Under Namespace

Modules: Adapters, ApplicationHelper, Config, Extensions, Generators, MainHelper, Support Classes: AbstractModel, ActionNotAllowed, ApplicationController, CSVConverter, Engine, FormBuilder, HashHelper, ImportmapFormatter, InstallGenerator, MainController, ModelNotFound, ObjectNotFound, Version

Constant Summary collapse

EXTENSIONS =

rubocop:disable Style/MutableConstant

[]
AUTHORIZATION_ADAPTERS =

rubocop:disable Style/MutableConstant

{}
AUDITING_ADAPTERS =

rubocop:disable Style/MutableConstant

{}
CONFIGURATION_ADAPTERS =

rubocop:disable Style/MutableConstant

{}

Class Method Summary collapse

Methods included from Config::ConstLoadSuppressor

allowing, suppressing

Class Method Details

.add_extension(extension_key, extension_definition, options = {}) ⇒ Object

Extend RailsAdmin

The extension may define various adapters (e.g., for authorization) and register those via the options hash.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rails_admin/extension.rb', line 15

def self.add_extension(extension_key, extension_definition, options = {})
  options.assert_valid_keys(:authorization, :configuration, :auditing)

  EXTENSIONS << extension_key

  AUTHORIZATION_ADAPTERS[extension_key] = extension_definition::AuthorizationAdapter if options[:authorization]

  CONFIGURATION_ADAPTERS[extension_key] = extension_definition::ConfigurationAdapter if options[:configuration]

  AUDITING_ADAPTERS[extension_key] = extension_definition::AuditingAdapter if options[:auditing]
end

.config(entity = nil, &block) ⇒ Object

Setup RailsAdmin

Given the first argument is a model class, a model class name or an abstract model object proxies to model configuration method.

If only a block is passed it is stored to initializer stack to be evaluated on first request in production mode and on each request in development. If initialization has already occurred (in other words RailsAdmin.setup has been called) the block will be added to stack and evaluated at once.

Otherwise returns RailsAdmin::Config class.

See Also:



31
32
33
34
35
36
37
38
39
# File 'lib/rails_admin.rb', line 31

def self.config(entity = nil, &block)
  if entity
    RailsAdmin::Config.model(entity, &block)
  elsif block_given?
    RailsAdmin::Config::ConstLoadSuppressor.suppressing { yield(RailsAdmin::Config) }
  else
    RailsAdmin::Config
  end
end

.setup_all_extensionsObject

Setup all extensions for testing



28
29
30
31
32
33
34
# File 'lib/rails_admin/extension.rb', line 28

def self.setup_all_extensions
  (AUTHORIZATION_ADAPTERS.values + AUDITING_ADAPTERS.values).each do |klass|
    klass.setup if klass.respond_to? :setup
  rescue # rubocop:disable Style/RescueStandardError
    # ignore errors
  end
end

.yaml_dump(object) ⇒ Object



59
60
61
# File 'lib/rails_admin.rb', line 59

def self.yaml_dump(object)
  YAML.dump(object)
end