Module: RailsAdmin

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/support/i18n.rb,
lib/rails_admin/config/fields.rb,
lib/rails_admin/abstract_model.rb,
lib/rails_admin/bootstrap-sass.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/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,
lib/rails_admin/extensions/history/history.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/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/fields/types/datetime.rb,
lib/rails_admin/config/fields/types/password.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/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/abstract_object.rb,
app/controllers/rails_admin/application_controller.rb,
lib/rails_admin/adapters/active_record/association.rb,
lib/rails_admin/config/fields/types/active_storage.rb,
lib/rails_admin/config/fields/types/bson_object_id.rb,
lib/rails_admin/extensions/history/auditing_adapter.rb,
lib/rails_admin/adapters/active_record/abstract_object.rb,
lib/rails_admin/config/fields/types/active_record_enum.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, Bootstrap, Config, Extensions, Generators, MainHelper, Support Classes: AbstractModel, ActionNotAllowed, ApplicationController, CSVConverter, Engine, FormBuilder, HashHelper, History, 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

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.


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_admin/extension.rb', line 13

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

  EXTENSIONS << extension_key

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

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

  if options[:auditing]
    AUDITING_ADAPTERS[extension_key] = extension_definition::AuditingAdapter
  end
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 occured (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:


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

def self.config(entity = nil, &block)
  if entity
    RailsAdmin::Config.model(entity, &block)
  elsif block_given?
    block.call(RailsAdmin::Config)
  else
    RailsAdmin::Config
  end
end

.setup_all_extensionsObject

Setup all extensions for testing


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

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

.yaml_dump(object) ⇒ Object


55
56
57
# File 'lib/rails_admin.rb', line 55

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