diff --git a/README.md b/README.md index b905b5367b..ae72e4c123 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,13 @@ If you have good reasons to think you found a *rails_admin* bug, submit a ticket API Update Note --------------- +`ActiveRecord::Base.rails_admin` is the new recommendation for configuring +models. The old API is not deprecated as the new one is just a proxy for +`RailsAdmin::Config.model`. + +`navigation.max_visible_tabs` is not configurable anymore, as the new Activo +theme implements the main navigation as a vertical list. + `object_label` is not directly configurable anymore, as it lead to performance issues when used with a list of records. Please use object_label_method instead. @@ -115,10 +122,31 @@ RailsAdmin provides its out of the box administrative interface by inspecting yo models and following some Rails conventions. For a more tailored experience, it also provides a configuration DSL which allows you to customize many aspects of the interface. -The configuration code should be placed in an initializer file, for example: +The configuration code should be placed within model classes, for example: + + app/models/team.rb + + class Team < ActiveRecord::Base + rails_admin do + label "List of teams" + end + end + +Configuration code that is not specific to any model, such as options listed in +the following General section and later in Mass Assignment Operations, should +be placed in an initializer file, for example: config/initializers/rails_admin.rb + RailsAdmin.config do |config| + config.models do + list do + fields_of_type :datetime do + date_format :compact + end + end + end + end ### General @@ -163,8 +191,8 @@ sure that new models are not automatically added to RailsAdmin, e.g. because of If you need to customize the label of the model, use: - RailsAdmin.config do |config| - config.model Team do + class Team < ActiveRecord::Base + rails_admin do label "List of teams" end end @@ -190,15 +218,13 @@ related models and for part of the audit information stored in the history records--so keep in mind that this configuration option has widespread effects. - RailsAdmin.config do |config| - config.model Team do + class Team < ActiveRecord::Base + rails_admin do object_label_method do :custom_label_method end end - end - - def Team