elucid-rails_admin 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +54 -0
- data/LICENSE.md +20 -0
- data/README.md +1334 -0
- data/Rakefile +14 -0
- data/app/assets/images/rails_admin/aristo/images/bg_fallback.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/icon_sprite.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/progress_bar.gif +0 -0
- data/app/assets/images/rails_admin/aristo/images/slider_handles.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/images/rails_admin/bullet_black.png +0 -0
- data/app/assets/images/rails_admin/bullet_white.png +0 -0
- data/app/assets/images/rails_admin/calendar.png +0 -0
- data/app/assets/images/rails_admin/clock.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_r.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_select.gif +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_rgb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_rgb_g.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_rgb_r.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/select.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/select2.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/slider.png +0 -0
- data/app/assets/images/rails_admin/logo.png +0 -0
- data/app/assets/images/rails_admin/magnifier.png +0 -0
- data/app/assets/images/rails_admin/multiselect/icon_sprite.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-dark.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-light.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-dark.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-light.png +0 -0
- data/app/assets/javascripts/rails_admin/custom/ui.js +1 -0
- data/app/assets/javascripts/rails_admin/jquery-ui-1.8.16.custom.js +5019 -0
- data/app/assets/javascripts/rails_admin/jquery.colorpicker.js +484 -0
- data/app/assets/javascripts/rails_admin/jquery.ui.timepicker.js +1219 -0
- data/app/assets/javascripts/rails_admin/ra.datetimepicker.js +67 -0
- data/app/assets/javascripts/rails_admin/ra.filter-box.js +119 -0
- data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +280 -0
- data/app/assets/javascripts/rails_admin/ra.filtering-select.js +181 -0
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +147 -0
- data/app/assets/javascripts/rails_admin/rails_admin.js.erb +17 -0
- data/app/assets/javascripts/rails_admin/themes/default/ui.js +1 -0
- data/app/assets/javascripts/rails_admin/ui.js.coffee +30 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/icon_sprite.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/progress_bar.gif +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/slider_handles.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/jquery-ui-1.8.7.custom.css.scss +733 -0
- data/app/assets/stylesheets/rails_admin/base/README +2 -0
- data/app/assets/stylesheets/rails_admin/base/mixins.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/base/theming.css.scss +102 -0
- data/app/assets/stylesheets/rails_admin/base/variables.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/custom/README +3 -0
- data/app/assets/stylesheets/rails_admin/custom/mixins.css.scss +9 -0
- data/app/assets/stylesheets/rails_admin/custom/theming.css.scss +11 -0
- data/app/assets/stylesheets/rails_admin/custom/variables.css.scss +11 -0
- data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +51 -0
- data/app/assets/stylesheets/rails_admin/jquery.colorpicker.css.scss +180 -0
- data/app/assets/stylesheets/rails_admin/jquery.ui.timepicker.css.scss +53 -0
- data/app/assets/stylesheets/rails_admin/ra.calendar-additions.css.scss +25 -0
- data/app/assets/stylesheets/rails_admin/ra.filtering-multiselect.css.scss +85 -0
- data/app/assets/stylesheets/rails_admin/rails_admin.css +4 -0
- data/app/assets/stylesheets/rails_admin/themes/README +11 -0
- data/app/assets/stylesheets/rails_admin/themes/default/mixins.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/themes/default/theming.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/themes/default/variables.css.scss +1 -0
- data/app/controllers/rails_admin/application_controller.rb +62 -0
- data/app/controllers/rails_admin/history_controller.rb +26 -0
- data/app/controllers/rails_admin/main_controller.rb +371 -0
- data/app/helpers/rails_admin/application_helper.rb +65 -0
- data/app/helpers/rails_admin/form_builder.rb +52 -0
- data/app/helpers/rails_admin/main_helper.rb +100 -0
- data/app/models/rails_admin/history.rb +64 -0
- data/app/views/kaminari/twitter-bootstrap/_gap.html.haml +2 -0
- data/app/views/kaminari/twitter-bootstrap/_next_page.html.haml +4 -0
- data/app/views/kaminari/twitter-bootstrap/_page.html.haml +4 -0
- data/app/views/kaminari/twitter-bootstrap/_paginator.html.haml +10 -0
- data/app/views/kaminari/twitter-bootstrap/_prev_page.html.haml +4 -0
- data/app/views/layouts/rails_admin/_navigation.html.haml +19 -0
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +9 -0
- data/app/views/layouts/rails_admin/application.html.haml +41 -0
- data/app/views/rails_admin/history/_dashboard.html.haml +10 -0
- data/app/views/rails_admin/history/show.html.haml +42 -0
- data/app/views/rails_admin/main/_delete_notice.html.haml +19 -0
- data/app/views/rails_admin/main/_form_colorpicker.html.haml +26 -0
- data/app/views/rails_admin/main/_form_datetime.html.haml +7 -0
- data/app/views/rails_admin/main/_form_enumeration.html.haml +5 -0
- data/app/views/rails_admin/main/_form_field.html.haml +1 -0
- data/app/views/rails_admin/main/_form_file_upload.html.haml +19 -0
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +57 -0
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +47 -0
- data/app/views/rails_admin/main/_form_polymorphic_association.html.haml +36 -0
- data/app/views/rails_admin/main/_form_text.html.haml +13 -0
- data/app/views/rails_admin/main/_models_links.html.haml +31 -0
- data/app/views/rails_admin/main/_object_links.html.haml +23 -0
- data/app/views/rails_admin/main/_submit_buttons.html.haml +12 -0
- data/app/views/rails_admin/main/bulk_delete.html.haml +6 -0
- data/app/views/rails_admin/main/dashboard.html.haml +31 -0
- data/app/views/rails_admin/main/delete.html.haml +13 -0
- data/app/views/rails_admin/main/edit.html.haml +2 -0
- data/app/views/rails_admin/main/export.html.haml +70 -0
- data/app/views/rails_admin/main/index.html.haml +98 -0
- data/app/views/rails_admin/main/new.html.haml +2 -0
- data/app/views/rails_admin/main/show.html.haml +14 -0
- data/config/initializers/active_record_extensions.rb +19 -0
- data/config/initializers/devise_patch.rb +9 -0
- data/config/initializers/haml.rb +3 -0
- data/config/locales/devise.bg.yml +42 -0
- data/config/locales/devise.de.yml +39 -0
- data/config/locales/devise.en.yml +39 -0
- data/config/locales/devise.es.yml +39 -0
- data/config/locales/devise.fi.yml +39 -0
- data/config/locales/devise.fr.yml +78 -0
- data/config/locales/devise.hr.yml +49 -0
- data/config/locales/devise.it.yml +39 -0
- data/config/locales/devise.lt.yml +39 -0
- data/config/locales/devise.mn.yml +39 -0
- data/config/locales/devise.nb.yml +43 -0
- data/config/locales/devise.pt-BR.yml +39 -0
- data/config/locales/devise.pt-PT.yml +39 -0
- data/config/locales/devise.ro.yml +46 -0
- data/config/locales/devise.ru.yml +39 -0
- data/config/locales/devise.sv.yml +39 -0
- data/config/locales/devise.tr.yml +39 -0
- data/config/locales/devise.uk.yml +39 -0
- data/config/locales/devise.zh-CN.yml +39 -0
- data/config/locales/devise.zh_cn.yml +39 -0
- data/config/locales/rails_admin.bg.yml +104 -0
- data/config/locales/rails_admin.da.yml +99 -0
- data/config/locales/rails_admin.de.yml +110 -0
- data/config/locales/rails_admin.en.yml +114 -0
- data/config/locales/rails_admin.es.yml +112 -0
- data/config/locales/rails_admin.fi.yml +107 -0
- data/config/locales/rails_admin.fr.yml +110 -0
- data/config/locales/rails_admin.hr.yml +81 -0
- data/config/locales/rails_admin.it.yml +109 -0
- data/config/locales/rails_admin.ja.yml +110 -0
- data/config/locales/rails_admin.lt.yml +102 -0
- data/config/locales/rails_admin.lv.yml +100 -0
- data/config/locales/rails_admin.mn.yml +103 -0
- data/config/locales/rails_admin.nb.yml +110 -0
- data/config/locales/rails_admin.nl.yml +135 -0
- data/config/locales/rails_admin.pl.yml +111 -0
- data/config/locales/rails_admin.pt-BR.yml +109 -0
- data/config/locales/rails_admin.pt-PT.yml +109 -0
- data/config/locales/rails_admin.ro.yml +113 -0
- data/config/locales/rails_admin.ru.yml +109 -0
- data/config/locales/rails_admin.sv.yml +103 -0
- data/config/locales/rails_admin.tr.yml +103 -0
- data/config/locales/rails_admin.uk.yml +100 -0
- data/config/locales/rails_admin.zh-CN.yml +114 -0
- data/config/locales/rails_admin.zh_cn.yml +107 -0
- data/config/routes.rb +28 -0
- data/lib/generators/rails_admin/install_generator.rb +83 -0
- data/lib/generators/rails_admin/templates/drop.rb +18 -0
- data/lib/generators/rails_admin/templates/initializer.erb +150 -0
- data/lib/generators/rails_admin/templates/migration.rb +18 -0
- data/lib/generators/rails_admin/uninstall_generator.rb +22 -0
- data/lib/generators/rails_admin/utils.rb +30 -0
- data/lib/rails_admin.rb +57 -0
- data/lib/rails_admin/abstract_model.rb +73 -0
- data/lib/rails_admin/abstract_object.rb +28 -0
- data/lib/rails_admin/adapters/active_record.rb +359 -0
- data/lib/rails_admin/config.rb +287 -0
- data/lib/rails_admin/config/base.rb +111 -0
- data/lib/rails_admin/config/fields.rb +99 -0
- data/lib/rails_admin/config/fields/association.rb +101 -0
- data/lib/rails_admin/config/fields/base.rb +273 -0
- data/lib/rails_admin/config/fields/factories/carrierwave.rb +16 -0
- data/lib/rails_admin/config/fields/factories/devise.rb +31 -0
- data/lib/rails_admin/config/fields/factories/dragonfly.rb +20 -0
- data/lib/rails_admin/config/fields/factories/enum.rb +11 -0
- data/lib/rails_admin/config/fields/factories/paperclip.rb +26 -0
- data/lib/rails_admin/config/fields/factories/password.rb +17 -0
- data/lib/rails_admin/config/fields/group.rb +63 -0
- data/lib/rails_admin/config/fields/groupable.rb +25 -0
- data/lib/rails_admin/config/fields/types.rb +26 -0
- data/lib/rails_admin/config/fields/types/all.rb +22 -0
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +51 -0
- data/lib/rails_admin/config/fields/types/boolean.rb +29 -0
- data/lib/rails_admin/config/fields/types/carrierwave.rb +32 -0
- data/lib/rails_admin/config/fields/types/color.rb +37 -0
- data/lib/rails_admin/config/fields/types/date.rb +24 -0
- data/lib/rails_admin/config/fields/types/datetime.rb +160 -0
- data/lib/rails_admin/config/fields/types/decimal.rb +14 -0
- data/lib/rails_admin/config/fields/types/dragonfly.rb +51 -0
- data/lib/rails_admin/config/fields/types/enum.rb +35 -0
- data/lib/rails_admin/config/fields/types/file_upload.rb +54 -0
- data/lib/rails_admin/config/fields/types/float.rb +14 -0
- data/lib/rails_admin/config/fields/types/has_and_belongs_to_many_association.rb +14 -0
- data/lib/rails_admin/config/fields/types/has_many_association.rb +42 -0
- data/lib/rails_admin/config/fields/types/has_one_association.rb +31 -0
- data/lib/rails_admin/config/fields/types/integer.rb +24 -0
- data/lib/rails_admin/config/fields/types/paperclip.rb +38 -0
- data/lib/rails_admin/config/fields/types/password.rb +41 -0
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +78 -0
- data/lib/rails_admin/config/fields/types/string.rb +34 -0
- data/lib/rails_admin/config/fields/types/text.rb +39 -0
- data/lib/rails_admin/config/fields/types/time.rb +31 -0
- data/lib/rails_admin/config/fields/types/timestamp.rb +18 -0
- data/lib/rails_admin/config/has_fields.rb +112 -0
- data/lib/rails_admin/config/has_groups.rb +39 -0
- data/lib/rails_admin/config/hideable.rb +28 -0
- data/lib/rails_admin/config/model.rb +89 -0
- data/lib/rails_admin/config/proxy.rb +40 -0
- data/lib/rails_admin/config/sections.rb +51 -0
- data/lib/rails_admin/config/sections/create.rb +11 -0
- data/lib/rails_admin/config/sections/export.rb +18 -0
- data/lib/rails_admin/config/sections/list.rb +55 -0
- data/lib/rails_admin/config/sections/navigation.rb +21 -0
- data/lib/rails_admin/config/sections/show.rb +50 -0
- data/lib/rails_admin/config/sections/update.rb +11 -0
- data/lib/rails_admin/engine.rb +15 -0
- data/lib/rails_admin/extension.rb +23 -0
- data/lib/rails_admin/extensions/cancan.rb +5 -0
- data/lib/rails_admin/extensions/cancan/authorization_adapter.rb +71 -0
- data/lib/rails_admin/generic_support.rb +15 -0
- data/lib/rails_admin/i18n_support.rb +43 -0
- data/lib/rails_admin/support/core_extensions.rb +44 -0
- data/lib/rails_admin/support/csv_converter.rb +109 -0
- data/lib/rails_admin/version.rb +6 -0
- data/lib/tasks/prepare_ci_env.rake +27 -0
- data/lib/tasks/rails_admin.rake +18 -0
- data/spec/ci.sh +2 -0
- data/spec/controllers/application_controller_spec.rb +30 -0
- data/spec/controllers/main_controller_spec.rb +86 -0
- data/spec/database_helpers.rb +15 -0
- data/spec/dummy_app/Gemfile +52 -0
- data/spec/dummy_app/README +256 -0
- data/spec/dummy_app/Rakefile +7 -0
- data/spec/dummy_app/app/controllers/application_controller.rb +3 -0
- data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_app/app/locales/models.en.yml +8 -0
- data/spec/dummy_app/app/models/abstract.rb +5 -0
- data/spec/dummy_app/app/models/ball.rb +8 -0
- data/spec/dummy_app/app/models/cms.rb +5 -0
- data/spec/dummy_app/app/models/cms/basic_page.rb +7 -0
- data/spec/dummy_app/app/models/cms/unscoped_page.rb +3 -0
- data/spec/dummy_app/app/models/comment.rb +3 -0
- data/spec/dummy_app/app/models/division.rb +8 -0
- data/spec/dummy_app/app/models/draft.rb +11 -0
- data/spec/dummy_app/app/models/fan.rb +5 -0
- data/spec/dummy_app/app/models/field_test.rb +13 -0
- data/spec/dummy_app/app/models/league.rb +10 -0
- data/spec/dummy_app/app/models/player.rb +15 -0
- data/spec/dummy_app/app/models/rel_test.rb +6 -0
- data/spec/dummy_app/app/models/team.rb +25 -0
- data/spec/dummy_app/app/models/user.rb +21 -0
- data/spec/dummy_app/app/uploaders/carrierwave_uploader.rb +53 -0
- data/spec/dummy_app/app/views/layouts/application.html.erb +13 -0
- data/spec/dummy_app/config.ru +4 -0
- data/spec/dummy_app/config/application.rb +47 -0
- data/spec/dummy_app/config/boot.rb +6 -0
- data/spec/dummy_app/config/database.yml +22 -0
- data/spec/dummy_app/config/environment.rb +5 -0
- data/spec/dummy_app/config/environments/development.rb +27 -0
- data/spec/dummy_app/config/environments/production.rb +51 -0
- data/spec/dummy_app/config/environments/test.rb +39 -0
- data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_app/config/initializers/devise.rb +142 -0
- data/spec/dummy_app/config/initializers/inflections.rb +10 -0
- data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
- data/spec/dummy_app/config/initializers/quiet_assets.rb +10 -0
- data/spec/dummy_app/config/initializers/rails_admin.rb +10 -0
- data/spec/dummy_app/config/initializers/secret_token.rb +7 -0
- data/spec/dummy_app/config/initializers/session_store.rb +8 -0
- data/spec/dummy_app/config/routes.rb +8 -0
- data/spec/dummy_app/db/migrate/00000000000001_create_divisions_migration.rb +13 -0
- data/spec/dummy_app/db/migrate/00000000000002_create_drafts_migration.rb +19 -0
- data/spec/dummy_app/db/migrate/00000000000003_create_leagues_migration.rb +12 -0
- data/spec/dummy_app/db/migrate/00000000000004_create_players_migration.rb +20 -0
- data/spec/dummy_app/db/migrate/00000000000005_create_teams_migration.rb +22 -0
- data/spec/dummy_app/db/migrate/00000000000006_devise_create_users.rb +19 -0
- data/spec/dummy_app/db/migrate/00000000000007_create_histories_table.rb +16 -0
- data/spec/dummy_app/db/migrate/00000000000008_create_fans_migration.rb +12 -0
- data/spec/dummy_app/db/migrate/00000000000009_create_fans_teams_migration.rb +11 -0
- data/spec/dummy_app/db/migrate/00000000000010_add_revenue_to_team_migration.rb +9 -0
- data/spec/dummy_app/db/migrate/00000000000011_add_suspended_to_player_migration.rb +9 -0
- data/spec/dummy_app/db/migrate/00000000000012_add_avatar_columns_to_user.rb +16 -0
- data/spec/dummy_app/db/migrate/00000000000013_add_roles_to_user.rb +9 -0
- data/spec/dummy_app/db/migrate/00000000000014_add_color_to_team_migration.rb +9 -0
- data/spec/dummy_app/db/migrate/20101223222233_create_rel_tests.rb +15 -0
- data/spec/dummy_app/db/migrate/20110103205808_create_comments.rb +15 -0
- data/spec/dummy_app/db/migrate/20110123042530_rename_histories_to_rails_admin_histories.rb +9 -0
- data/spec/dummy_app/db/migrate/20110224184303_create_field_tests.rb +22 -0
- data/spec/dummy_app/db/migrate/20110328193014_create_cms_basic_pages.rb +14 -0
- data/spec/dummy_app/db/migrate/20110329183136_remove_league_id_from_teams.rb +9 -0
- data/spec/dummy_app/db/migrate/20110607152842_add_format_to_field_test.rb +9 -0
- data/spec/dummy_app/db/migrate/20110714095433_create_balls.rb +12 -0
- data/spec/dummy_app/db/migrate/20110831090841_add_protected_field_and_restricted_field_to_field_tests.rb +6 -0
- data/spec/dummy_app/db/migrate/20110901131551_change_division_primary_key.rb +19 -0
- data/spec/dummy_app/db/migrate/20110901142530_rename_league_id_foreign_key_on_divisions.rb +5 -0
- data/spec/dummy_app/db/migrate/20110901150912_set_primary_key_not_null_for_divisions.rb +21 -0
- data/spec/dummy_app/db/migrate/20110901154834_change_length_for_rails_admin_histories.rb +9 -0
- data/spec/dummy_app/db/migrate/20111103174459_create_unscoped_pages.rb +9 -0
- data/spec/dummy_app/db/migrate/20111108143642_add_dragonfly_and_carrierwave_to_field_tests.rb +7 -0
- data/spec/dummy_app/db/seeds.rb +18 -0
- data/spec/dummy_app/doc/README_FOR_APP +2 -0
- data/spec/dummy_app/public/404.html +0 -0
- data/spec/dummy_app/public/favicon.ico +0 -0
- data/spec/dummy_app/script/rails +6 -0
- data/spec/factories.rb +62 -0
- data/spec/generator_helpers.rb +30 -0
- data/spec/generators/install_generator_spec.rb +85 -0
- data/spec/generators/uninstall_generator_spec.rb +35 -0
- data/spec/lib/abstract_object_spec.rb +119 -0
- data/spec/lib/rails_admin_spec.rb +153 -0
- data/spec/requests/authorization/cancan_spec.rb +260 -0
- data/spec/requests/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +25 -0
- data/spec/requests/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +55 -0
- data/spec/requests/basic/create/rails_admin_basic_create_spec.rb +143 -0
- data/spec/requests/basic/create/rails_admin_namespaced_model_create_spec.rb +24 -0
- data/spec/requests/basic/delete/rails_admin_basic_delete_spec.rb +35 -0
- data/spec/requests/basic/destroy/rails_admin_basic_destroy_spec.rb +56 -0
- data/spec/requests/basic/edit/rails_admin_basic_edit_spec.rb +98 -0
- data/spec/requests/basic/export/rails_admin_basic_export_spec.rb +84 -0
- data/spec/requests/basic/list/rails_admin_basic_list_spec.rb +401 -0
- data/spec/requests/basic/new/rails_admin_basic_new_spec.rb +74 -0
- data/spec/requests/basic/new/rails_admin_namespaced_model_new_spec.rb +31 -0
- data/spec/requests/basic/show/rails_admin_basic_show_spec.rb +83 -0
- data/spec/requests/basic/update/rails_admin_basic_update_spec.rb +169 -0
- data/spec/requests/config/edit/rails_admin_config_edit_spec.rb +744 -0
- data/spec/requests/config/list/rails_admin_config_list_spec.rb +549 -0
- data/spec/requests/config/navigation/rails_admin_config_navigation_spec.rb +107 -0
- data/spec/requests/config/rails_admin_config_spec.rb +180 -0
- data/spec/requests/config/show/rails_admin_config_show_spec.rb +275 -0
- data/spec/requests/history/rails_admin_history_spec.rb +57 -0
- data/spec/requests/rails_admin_spec.rb +103 -0
- data/spec/requests/relation_spec.rb +26 -0
- data/spec/spec_helper.rb +88 -0
- metadata +717 -0
data/Gemfile
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
source 'http://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Bundle gems for the local environment. Make sure to
|
|
4
|
+
# put test-only gems in this group so their generators
|
|
5
|
+
# and rake tasks are available in development mode:
|
|
6
|
+
group :development, :test do
|
|
7
|
+
platforms :jruby do
|
|
8
|
+
gem 'jruby-openssl', '~> 0.7'
|
|
9
|
+
# activerecord-jdbc-adapter does not yet have a rails 3.1 compatible release
|
|
10
|
+
gem 'activerecord-jdbc-adapter', :git => 'git://github.com/jruby/activerecord-jdbc-adapter.git'
|
|
11
|
+
case ENV['CI_DB_ADAPTER']
|
|
12
|
+
when 'mysql'
|
|
13
|
+
gem 'activerecord-jdbcmysql-adapter', '~> 1.2'
|
|
14
|
+
gem 'jdbc-mysql', '~> 5.1'
|
|
15
|
+
when 'postgresql'
|
|
16
|
+
gem 'activerecord-jdbcpostgresql-adapter', '~> 1.2'
|
|
17
|
+
gem 'jdbc-postgres', '~> 9.0'
|
|
18
|
+
else
|
|
19
|
+
gem 'activerecord-jdbcsqlite3-adapter', '~> 1.2'
|
|
20
|
+
gem 'jdbc-sqlite3', '~> 3.6'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
platforms :ruby, :mswin, :mingw do
|
|
25
|
+
case ENV['CI_DB_ADAPTER']
|
|
26
|
+
when 'mysql'
|
|
27
|
+
gem 'mysql', '~> 2.8'
|
|
28
|
+
when 'postgresql'
|
|
29
|
+
gem 'pg', '~> 0.10'
|
|
30
|
+
else
|
|
31
|
+
gem 'sqlite3', '~> 1.3'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
gem 'cancan'
|
|
36
|
+
gem 'silent-postgres'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
group :debug do
|
|
40
|
+
platform :mri_18 do
|
|
41
|
+
gem 'ruby-debug'
|
|
42
|
+
gem 'linecache', '<= 0.45'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
platform :mri_19 do
|
|
46
|
+
gem 'ruby-debug19'
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
platforms :jruby, :mingw_18, :ruby_18 do
|
|
51
|
+
gem 'fastercsv', '~> 1.5'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
gemspec
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2010 Erik Michaels-Ober
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,1334 @@
|
|
|
1
|
+
# RailsAdmin
|
|
2
|
+
|
|
3
|
+
RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data.
|
|
4
|
+
|
|
5
|
+
[](http://travis-ci.org/sferik/rails_admin)
|
|
6
|
+
|
|
7
|
+
[](http://www.pledgie.com/campaigns/15917)
|
|
8
|
+
|
|
9
|
+
RailsAdmin started as a port of [MerbAdmin](https://github.com/sferik/merb-admin) to Rails 3
|
|
10
|
+
and was implemented as a [Ruby Summer of Code project](http://www.rubysoc.org/projects)
|
|
11
|
+
by [Bogdan Gaza](https://github.com/hurrycane) with mentors [Erik Michaels-Ober](https://github.com/sferik),
|
|
12
|
+
[Yehuda Katz](https://github.com/wycats),
|
|
13
|
+
[Luke van der Hoeven](https://github.com/plukevdh), and [Rein Henrichs](https://github.com/reinh).
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
* Display database tables
|
|
18
|
+
* Create new data
|
|
19
|
+
* Easily update data
|
|
20
|
+
* Safely delete data
|
|
21
|
+
* Automatic form validation
|
|
22
|
+
* Search and filtering
|
|
23
|
+
* Export data to CSV/JSON/XML
|
|
24
|
+
* Authentication (via [Devise](https://github.com/plataformatec/devise))
|
|
25
|
+
* User action history
|
|
26
|
+
|
|
27
|
+
See the demo here:
|
|
28
|
+
http://rails-admin-tb.herokuapp.com
|
|
29
|
+
|
|
30
|
+
### Supported ORMs:
|
|
31
|
+
|
|
32
|
+
* ActiveRecord
|
|
33
|
+
|
|
34
|
+
## <a name="support">Support</a>
|
|
35
|
+
If you have a question, you can ask the [official RailsAdmin mailing
|
|
36
|
+
list](http://groups.google.com/group/rails_admin) or ping sferik on IRC in
|
|
37
|
+
[#railsadmin on
|
|
38
|
+
irc.freenode.net](http://webchat.freenode.net/?channels=railsadmin).
|
|
39
|
+
|
|
40
|
+
Check this README and the wiki first.
|
|
41
|
+
|
|
42
|
+
If you think you found a bug in RailsAdmin, you can [submit an
|
|
43
|
+
issue](https://github.com/sferik/rails_admin#issues)
|
|
44
|
+
No feature requests or questions please (the mailing list is active).
|
|
45
|
+
See at the bottom of this README for contributing.
|
|
46
|
+
|
|
47
|
+
## <a name="screenshots">Screenshots</a>
|
|
48
|
+

|
|
49
|
+

|
|
50
|
+

|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
## <a name="installation">Installation</a>
|
|
54
|
+
In your `Gemfile`, add the following dependencies:
|
|
55
|
+
|
|
56
|
+
gem 'fastercsv' # Only required on Ruby 1.8 and below
|
|
57
|
+
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
|
|
58
|
+
|
|
59
|
+
Run:
|
|
60
|
+
|
|
61
|
+
$ bundle install
|
|
62
|
+
|
|
63
|
+
And then run:
|
|
64
|
+
|
|
65
|
+
$ rails g rails_admin:install
|
|
66
|
+
|
|
67
|
+
This generator will install RailsAdmin and [Devise](https://github.com/plataformatec/devise) if you
|
|
68
|
+
don't already have it installed. [Devise](https://github.com/plataformatec/devise) is strongly
|
|
69
|
+
recommended to protect your data from anonymous users.
|
|
70
|
+
It will modify your `config/routes.rb`, adding:
|
|
71
|
+
|
|
72
|
+
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
|
|
73
|
+
|
|
74
|
+
And add an intializer that will help you getting started. (head for config/initializers/rails_admin.rb)
|
|
75
|
+
|
|
76
|
+
To use the CKEditor with Upload function, add [Rails-CKEditor](https://github.com/galetahub/ckeditor) to your Gemfile (`gem 'ckeditor'`) and follow [Rails-CKEditor](https://github.com/galetahub/ckeditor) installation instructions.
|
|
77
|
+
|
|
78
|
+
You can configure more options of CKEditor "config.js" file following the [Api Documentation](http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html) .
|
|
79
|
+
|
|
80
|
+
### Asset pipeline
|
|
81
|
+
|
|
82
|
+
The master branch currently targets Rails 3.1. Older branch with 3.0 compatibility is present, but is no longer maintained.
|
|
83
|
+
|
|
84
|
+
If you are updating from a Rails 3.0 application, you will no longer need to
|
|
85
|
+
update your assets, they will be served from the engine (through Sprockets).
|
|
86
|
+
You can delete all RailsAdmin related assets in your public directory.
|
|
87
|
+
RailsAdmin needs the asset pipeline. Activate it in `application.rb`:
|
|
88
|
+
|
|
89
|
+
config.assets.enabled = true
|
|
90
|
+
|
|
91
|
+
Please note that `initializer/rails_admin.rb` is very likely to require access to your DB.
|
|
92
|
+
Thus if don't need access to your application at asset compilation time,
|
|
93
|
+
|
|
94
|
+
config.assets.initialize_on_precompile = false
|
|
95
|
+
|
|
96
|
+
will reduce your compilation time and is recommended.
|
|
97
|
+
Note that this is needed on **Heroku** if you set `compile = false` and don't versionate `public/assets`.
|
|
98
|
+
More here: http://devcenter.heroku.com/articles/rails31_heroku_cedar
|
|
99
|
+
|
|
100
|
+
If you still have issue with the asset pipeline:
|
|
101
|
+
|
|
102
|
+
* ake sure you are using latest Rails 3.1 and Sprockets release
|
|
103
|
+
* copy all asset related configuration from application.rb and environment/*.rb files from a fresh (`rails new dummy`) rails app
|
|
104
|
+
* remove old assets with `bundle exec rake assets:clean` when in development
|
|
105
|
+
* read thoroughly the [Rails Guide](http://guides.rubyonrails.org/asset_pipeline.html)
|
|
106
|
+
|
|
107
|
+
## <a name="usage">Usage</a>
|
|
108
|
+
Start the server:
|
|
109
|
+
|
|
110
|
+
$ rails server
|
|
111
|
+
|
|
112
|
+
You should now be able to administer your site at
|
|
113
|
+
[http://localhost:3000/admin](http://localhost:3000/admin).
|
|
114
|
+
|
|
115
|
+
## <a name="configuration">Configuration</a>
|
|
116
|
+
RailsAdmin provides its out of the box administrative interface by inspecting your application's
|
|
117
|
+
models and following some Rails conventions. For a more tailored experience, it also provides a
|
|
118
|
+
configuration DSL which allows you to customize many aspects of the interface.
|
|
119
|
+
|
|
120
|
+
A customized configuration guide is generated at installation in `config/initializers/rails_admin.rb`
|
|
121
|
+
|
|
122
|
+
Read it (!)
|
|
123
|
+
|
|
124
|
+
The configuration will be executed at startup time, once. (dev & production)
|
|
125
|
+
Rake tasks that load environment don't execute RailsAdmin initializer's block, for performance and DB migration status compatibility.
|
|
126
|
+
You can force it (true or false):
|
|
127
|
+
|
|
128
|
+
SKIP_RAILS_ADMIN_INITIALIZER=false rake mytask
|
|
129
|
+
|
|
130
|
+
### General
|
|
131
|
+
|
|
132
|
+
Set the application name:
|
|
133
|
+
|
|
134
|
+
RailsAdmin.config do |config|
|
|
135
|
+
config.main_app_name = ["Cool app", "BackOffice"]
|
|
136
|
+
end
|
|
137
|
+
# or somethig more dynamic
|
|
138
|
+
RailsAdmin.config do |config|
|
|
139
|
+
config.main_app_name = Proc.new { |controller| [ "Cool app", "BackOffice - #{controller.params[:action].try(:titleize)}" ] }
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
You can customize authentication by providing a custom block for `RailsAdmin.authenticate_with`.
|
|
143
|
+
To disable authentication, pass an empty block:
|
|
144
|
+
|
|
145
|
+
RailsAdmin.config do |config|
|
|
146
|
+
config.authenticate_with {}
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
You can exclude models from RailsAdmin by appending those models to `excluded_models`:
|
|
150
|
+
|
|
151
|
+
RailsAdmin.config do |config|
|
|
152
|
+
config.excluded_models << "ClassName"
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
You can display empty fields in show view with:
|
|
156
|
+
|
|
157
|
+
RailsAdmin.config do |config|
|
|
158
|
+
config.compact_show_view = false
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
You can customize the width of the list view with:
|
|
162
|
+
|
|
163
|
+
RailsAdmin.config do |config|
|
|
164
|
+
config.total_columns_width = 1000
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
**Whitelist Approach**
|
|
168
|
+
|
|
169
|
+
By default, RailsAdmin automatically discovers all the models in the system and adds them to its list of models to
|
|
170
|
+
be accessible through RailsAdmin. The `excluded_models` configuration above permits the blacklisting of individual model classes.
|
|
171
|
+
|
|
172
|
+
If you prefer a whitelist approach, then you can use the `included_models` configuration option instead:
|
|
173
|
+
|
|
174
|
+
RailsAdmin.config do |config|
|
|
175
|
+
config.included_models = ["Class1", "Class2", "Class3"]
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
Only the models explicitly listed will be put under RailsAdmin access, and the auto-discovery of models is skipped.
|
|
179
|
+
|
|
180
|
+
The blacklist is effective on top of that, still, so that if you also have:
|
|
181
|
+
|
|
182
|
+
RailsAdmin.config do |config|
|
|
183
|
+
config.excluded_models = ["Class1"]
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
then only `Class2` and `Class3` would be made available to RailsAdmin.
|
|
187
|
+
|
|
188
|
+
The whitelist approach may be useful if RailsAdmin is used only for a part of the application and you want to make
|
|
189
|
+
sure that new models are not automatically added to RailsAdmin, e.g. because of security concerns.
|
|
190
|
+
|
|
191
|
+
### Model Class and Instance Labels ###
|
|
192
|
+
|
|
193
|
+
**Setting the model's label**
|
|
194
|
+
|
|
195
|
+
If you need to customize the label of the model, use:
|
|
196
|
+
|
|
197
|
+
RailsAdmin.config do |config|
|
|
198
|
+
config.model Team do
|
|
199
|
+
label "List of teams"
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
This label will be used anywhere the model name is shown, e.g. on the navigation tabs,
|
|
204
|
+
Dashboard page, list pages, etc.
|
|
205
|
+
|
|
206
|
+
**The object_label_method method**
|
|
207
|
+
|
|
208
|
+
The model configuration has another option `object_label_method` which configures
|
|
209
|
+
the title display of a single database record, i.e. an instance of a model.
|
|
210
|
+
|
|
211
|
+
By default it tries to call "name" or "title" methods on the record in question. If the object responds to neither,
|
|
212
|
+
then the label will be constructed from the model's classname appended with its
|
|
213
|
+
database identifier. You can add label methods (or replace the default [:name, :title]) with:
|
|
214
|
+
|
|
215
|
+
RailsAdmin.config {|c| c.label_methods << :description}
|
|
216
|
+
|
|
217
|
+
This `object_label_method` value is used in a number of places in RailsAdmin--for instance for the
|
|
218
|
+
output of belongs to associations in the listing views of related models, for
|
|
219
|
+
the option labels of the relational fields' input widgets in the edit views of
|
|
220
|
+
related models and for part of the audit information stored in the history
|
|
221
|
+
records--so keep in mind that this configuration option has widespread
|
|
222
|
+
effects.
|
|
223
|
+
|
|
224
|
+
RailsAdmin.config do |config|
|
|
225
|
+
config.model Team do
|
|
226
|
+
object_label_method do
|
|
227
|
+
:custom_label_method
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def custom_label_method
|
|
232
|
+
"Team #{self.name}"
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
*Difference between `label` and `object_label`*
|
|
237
|
+
|
|
238
|
+
`label` and `object_label` are both model configuration options. `label` is used
|
|
239
|
+
whenever Rails Admin refers to a model class, while `object_label` is used whenever
|
|
240
|
+
Rails Admin refers to an instance of a model class (representing a single database record).
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
### Navigation ###
|
|
244
|
+
|
|
245
|
+
* hiding a model
|
|
246
|
+
* setting the model's label
|
|
247
|
+
* configuring the number of visible tabs
|
|
248
|
+
|
|
249
|
+
**Hiding a model**
|
|
250
|
+
|
|
251
|
+
You can hide a model from the top navigation by marking its `visible` option
|
|
252
|
+
as false:
|
|
253
|
+
|
|
254
|
+
By passing the value as an argument:
|
|
255
|
+
|
|
256
|
+
RailsAdmin.config do |config|
|
|
257
|
+
config.model Team do
|
|
258
|
+
visible false
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
Or by passing a block that will be lazy evaluated each time the option is read:
|
|
263
|
+
|
|
264
|
+
RailsAdmin.config do |config|
|
|
265
|
+
config.model Team do
|
|
266
|
+
visible { false }
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
These two examples also work as a generic example of how most of the
|
|
271
|
+
configuration options function within RailsAdmin. You can pass a value as an
|
|
272
|
+
argument `option_name value`, or you can pass in a block which will be
|
|
273
|
+
evaluated each time the option is read. Notable is that boolean options' reader
|
|
274
|
+
accessors will be appended with ? whereas the writers will not be. That is, if
|
|
275
|
+
you want to get the Team model's visibility, you use
|
|
276
|
+
`RailsAdmin.config(Team).visible?`.
|
|
277
|
+
|
|
278
|
+
**Create a navigation_label in navigation**
|
|
279
|
+
|
|
280
|
+
# Given there are the following models: League, Team and Division
|
|
281
|
+
|
|
282
|
+
RailsAdmin.config do |config|
|
|
283
|
+
config.model Team do
|
|
284
|
+
parent League
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
config.model Division do
|
|
288
|
+
parent League
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
Obtained navigation:
|
|
293
|
+
|
|
294
|
+
Dashboard
|
|
295
|
+
...
|
|
296
|
+
League # (non-clickable)
|
|
297
|
+
League
|
|
298
|
+
Division
|
|
299
|
+
Team
|
|
300
|
+
...
|
|
301
|
+
|
|
302
|
+
You probably want to change the name of the navigation_label.
|
|
303
|
+
This can be easily achieved with the 'navigation_label' method of the parent model.
|
|
304
|
+
|
|
305
|
+
Added to previous example:
|
|
306
|
+
|
|
307
|
+
RailsAdmin.config do |config|
|
|
308
|
+
config.model League do
|
|
309
|
+
navigation_label 'League related'
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
Obtained navigation:
|
|
314
|
+
|
|
315
|
+
Dashboard
|
|
316
|
+
...
|
|
317
|
+
League related # (non-clickable)
|
|
318
|
+
League
|
|
319
|
+
Division
|
|
320
|
+
Team
|
|
321
|
+
...
|
|
322
|
+
|
|
323
|
+
**Change models order in navigation**
|
|
324
|
+
|
|
325
|
+
By default, they are ordered by alphabetical order. If you need to override this, specify
|
|
326
|
+
a weight attribute. Default is 0. Lower values will bubble items to the top, higher values
|
|
327
|
+
will move them to the bottom. Items with same weight will still be ordered by alphabetical order.
|
|
328
|
+
The mechanism is fully compatible with navigation labels. Items will be ordered within their own
|
|
329
|
+
menu subset. (but parent will always be first inside his submenu).
|
|
330
|
+
|
|
331
|
+
Example:
|
|
332
|
+
|
|
333
|
+
RailsAdmin.config do |config|
|
|
334
|
+
config.model League do
|
|
335
|
+
navigation_label 'League related'
|
|
336
|
+
weight -1
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
The 'League related' navigation label will move to the topmost position.
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
### List view ###
|
|
344
|
+
|
|
345
|
+
* Number of items per page
|
|
346
|
+
* Number of items per page per model
|
|
347
|
+
* Default sorting
|
|
348
|
+
* Configure globally
|
|
349
|
+
* Configure per model
|
|
350
|
+
* Fields
|
|
351
|
+
* Visibility and ordering
|
|
352
|
+
* Label
|
|
353
|
+
* Output formatting
|
|
354
|
+
* Sortability
|
|
355
|
+
* Column CSS class
|
|
356
|
+
* Column width
|
|
357
|
+
|
|
358
|
+
**Number of items per page**
|
|
359
|
+
|
|
360
|
+
You can configure the default number of rows rendered per page:
|
|
361
|
+
|
|
362
|
+
RailsAdmin.config do |config|
|
|
363
|
+
config.default_items_per_page = 50
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
**Number of items per page per model**
|
|
367
|
+
|
|
368
|
+
You can also configure it per model:
|
|
369
|
+
|
|
370
|
+
RailsAdmin.config do |config|
|
|
371
|
+
config.model Team do
|
|
372
|
+
list do
|
|
373
|
+
items_per_page 100
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
**Default sorting**
|
|
379
|
+
|
|
380
|
+
By default, rows sorted by the field `id` in reverse order
|
|
381
|
+
|
|
382
|
+
You can change default behavior with use two options: `sort_by` and `sort_reverse`
|
|
383
|
+
|
|
384
|
+
**Default sorting - Configure globally**
|
|
385
|
+
|
|
386
|
+
RailsAdmin.config do |config|
|
|
387
|
+
config.models do
|
|
388
|
+
list do
|
|
389
|
+
sort_by :updated_at
|
|
390
|
+
sort_reverse true # already default for serials ids and dates
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
**Default sorting - Configure per model**
|
|
396
|
+
|
|
397
|
+
RailsAdmin.config do |config|
|
|
398
|
+
config.model Player do
|
|
399
|
+
list do
|
|
400
|
+
sort_by :name
|
|
401
|
+
sort_reverse false
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
**Fields - Sortability**
|
|
407
|
+
|
|
408
|
+
You can make a column non-sortable by setting the sortable option to false (1)
|
|
409
|
+
You can change the column that the field will actually sort on (2)
|
|
410
|
+
Belongs_to associations :
|
|
411
|
+
will be sorted on their label if label is not virtual (:name, :title, etc.)
|
|
412
|
+
otherwise on the foreign_key (:team_id)
|
|
413
|
+
you can also specify a column on the targetted table (see example) (3)
|
|
414
|
+
|
|
415
|
+
RailsAdmin.config do |config|
|
|
416
|
+
config.model Player do
|
|
417
|
+
list do
|
|
418
|
+
field :created_at do # (1)
|
|
419
|
+
sortable false
|
|
420
|
+
end
|
|
421
|
+
field :name do # (2)
|
|
422
|
+
sortable :last_name # imagine there is a :last_name column and that :name is virtual
|
|
423
|
+
end
|
|
424
|
+
field :team do # (3)
|
|
425
|
+
# Will order by players playing with the best teams,
|
|
426
|
+
# rather than the team name (by default),
|
|
427
|
+
# or the team id (dull but default if object_label is not a column name)
|
|
428
|
+
|
|
429
|
+
sortable :win_percentage
|
|
430
|
+
|
|
431
|
+
# if you need to specify the join association name:
|
|
432
|
+
# (See #526 and http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html => table_aliasing)
|
|
433
|
+
sortable {:teams => :win_percentage}
|
|
434
|
+
# or
|
|
435
|
+
sortable "teams.win_percentage"
|
|
436
|
+
end
|
|
437
|
+
end
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
Default sort column is :id for ActiveRecord version
|
|
442
|
+
To change it:
|
|
443
|
+
RailsAdmin.config do |config|
|
|
444
|
+
config.model Team do
|
|
445
|
+
sort_by :name
|
|
446
|
+
end
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
By default, dates and serial ids are reversed when first-sorted ('desc' instead of 'asc' in SQL).
|
|
450
|
+
If you want to reverse (or cancel it) the default sort order (first column click or the default sort column):
|
|
451
|
+
|
|
452
|
+
RailsAdmin.config do |config|
|
|
453
|
+
config.model Team do
|
|
454
|
+
list do
|
|
455
|
+
field :id do
|
|
456
|
+
sort_reverse? false # will sort id increasing ('asc') first ones first (default is last ones first)
|
|
457
|
+
end
|
|
458
|
+
field :created_at do
|
|
459
|
+
sort_reverse? false # will sort dates increasing ('asc') first ones first (default is last ones first)
|
|
460
|
+
end
|
|
461
|
+
field :name do
|
|
462
|
+
sort_reverse? true # will sort name decreasing ('dec') z->a (default is a->z)
|
|
463
|
+
end
|
|
464
|
+
end
|
|
465
|
+
end
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
**Fields - Searchability**
|
|
469
|
+
|
|
470
|
+
You can make a column non-searchable by setting the searchable option to false (1)
|
|
471
|
+
You can change the column that the field will actually search on (2)
|
|
472
|
+
You can specify a list of column that will be searched over (3)
|
|
473
|
+
Belongs_to associations :
|
|
474
|
+
will be searched on their foreign_key (:team_id)
|
|
475
|
+
or on their label if label is not virtual (:name, :title, etc.)
|
|
476
|
+
you can also specify columns on the targetted table or the source table (see example) (4)
|
|
477
|
+
|
|
478
|
+
RailsAdmin.config do |config|
|
|
479
|
+
config.model Player do
|
|
480
|
+
list do
|
|
481
|
+
field :created_at do # (1)
|
|
482
|
+
searchable false
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
field :name do (2)
|
|
486
|
+
searchable :last_name
|
|
487
|
+
end
|
|
488
|
+
# OR
|
|
489
|
+
field :name do (3)
|
|
490
|
+
searchable [:first_name, :last_name]
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
field :team do # (4)
|
|
494
|
+
searchable [:name, :id]
|
|
495
|
+
# eq. to [Team => :name, Team => :id]
|
|
496
|
+
# or even [:name, Player => :team_id] will search on teams.name and players.team_id
|
|
497
|
+
|
|
498
|
+
# if you need to specify the join association name:
|
|
499
|
+
# (See #526 and http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html => table_aliasing)
|
|
500
|
+
searchable [{:teams => :name}, {:teams => :id}]
|
|
501
|
+
# or
|
|
502
|
+
searchable ["teams.name", "teams.id"]
|
|
503
|
+
end
|
|
504
|
+
end
|
|
505
|
+
end
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
Searchable definitions will be used for searches and filters.
|
|
509
|
+
You can independently deactivate querying (search) or filtering for each field with:
|
|
510
|
+
|
|
511
|
+
field :team do
|
|
512
|
+
searchable [:name, :color]
|
|
513
|
+
queryable? true # default
|
|
514
|
+
filterable? false
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
Empty filters can be displayed in the list view:
|
|
518
|
+
|
|
519
|
+
RailsAdmin.config do |config|
|
|
520
|
+
config.model Team do
|
|
521
|
+
list do
|
|
522
|
+
filters [:name, :division]
|
|
523
|
+
end
|
|
524
|
+
end
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
**Fields - Visibility and ordering**
|
|
529
|
+
|
|
530
|
+
By default all fields are visible, but they are not presented in any particular
|
|
531
|
+
order. If you specifically declare fields, only defined fields will be visible
|
|
532
|
+
and they will be presented in the order defined:
|
|
533
|
+
|
|
534
|
+
RailsAdmin.config do |config|
|
|
535
|
+
config.model Team do
|
|
536
|
+
list do
|
|
537
|
+
field :name
|
|
538
|
+
field :created_at
|
|
539
|
+
end
|
|
540
|
+
end
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
This would show only "name" and "created at" columns in the list view.
|
|
544
|
+
|
|
545
|
+
If you need to hide fields based on some logic on runtime (for instance
|
|
546
|
+
authorization to view field) you can pass a block for the `visible` option
|
|
547
|
+
(including its `hide` and `show` accessors):
|
|
548
|
+
|
|
549
|
+
RailsAdmin.config do |config|
|
|
550
|
+
config.model Team do
|
|
551
|
+
list do
|
|
552
|
+
field :name
|
|
553
|
+
field :created_at
|
|
554
|
+
field :revenue do
|
|
555
|
+
visible do
|
|
556
|
+
current_user.roles.include?(:accounting) # metacode
|
|
557
|
+
end
|
|
558
|
+
end
|
|
559
|
+
end
|
|
560
|
+
end
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
Note that above example's authorization conditional is not runnable code, just
|
|
564
|
+
an imaginary example. You need to provide RailsAdmin with your own
|
|
565
|
+
authorization scheme for which you can find a guide at the end of this file.
|
|
566
|
+
|
|
567
|
+
**Fields - Label**
|
|
568
|
+
|
|
569
|
+
The header of a list view column can be changed with the familiar label method:
|
|
570
|
+
|
|
571
|
+
RailsAdmin.config do |config|
|
|
572
|
+
config.model Team do
|
|
573
|
+
list do
|
|
574
|
+
field :name do
|
|
575
|
+
label "Title"
|
|
576
|
+
end
|
|
577
|
+
field :created_at do
|
|
578
|
+
label "Created on"
|
|
579
|
+
end
|
|
580
|
+
end
|
|
581
|
+
end
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
As in the previous example this would show only columns for fields "name" and
|
|
585
|
+
"created at" and their headers would have been renamed to "Title" and
|
|
586
|
+
"Created on".
|
|
587
|
+
|
|
588
|
+
**Fields - Output formatting**
|
|
589
|
+
|
|
590
|
+
The field's output can be modified:
|
|
591
|
+
|
|
592
|
+
RailsAdmin.config do |config|
|
|
593
|
+
config.model Team do
|
|
594
|
+
list do
|
|
595
|
+
field :name do
|
|
596
|
+
formatted_value do # used in form views
|
|
597
|
+
value.to_s.upcase
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
pretty_value do # used in list view columns and show views, defaults to formatted_value for non-association fields
|
|
601
|
+
value.titleize
|
|
602
|
+
end
|
|
603
|
+
|
|
604
|
+
export_value do
|
|
605
|
+
value.camelize # used in exports, where no html/data is allowed
|
|
606
|
+
end
|
|
607
|
+
end
|
|
608
|
+
field :created_at
|
|
609
|
+
end
|
|
610
|
+
end
|
|
611
|
+
end
|
|
612
|
+
|
|
613
|
+
This would render all the teams' names uppercased.
|
|
614
|
+
|
|
615
|
+
The field declarations also have access to a bindings hash which contains the
|
|
616
|
+
current record instance in key :object and the view instance in key :view.
|
|
617
|
+
Via :object we can access other columns' values and via :view we can access our
|
|
618
|
+
application's view helpers:
|
|
619
|
+
|
|
620
|
+
RailsAdmin.config do |config|
|
|
621
|
+
config.model Team do
|
|
622
|
+
list do
|
|
623
|
+
field :name do
|
|
624
|
+
formatted_value do
|
|
625
|
+
bindings[:view].tag(:img, { :src => bindings[:object].logo_url }) << value
|
|
626
|
+
end
|
|
627
|
+
end
|
|
628
|
+
field :created_at
|
|
629
|
+
end
|
|
630
|
+
end
|
|
631
|
+
end
|
|
632
|
+
|
|
633
|
+
This would output the name column prepended with team's logo using the `tag`
|
|
634
|
+
view helper. This example uses `value` method to access the name field's value,
|
|
635
|
+
but that could be written more verbosely as `bindings[:object].name`.
|
|
636
|
+
|
|
637
|
+
Fields of different date types (date, datetime, time, timestamp) have two extra
|
|
638
|
+
options to set the time formatting:
|
|
639
|
+
|
|
640
|
+
RailsAdmin.config do |config|
|
|
641
|
+
config.model Team do
|
|
642
|
+
list do
|
|
643
|
+
field :name
|
|
644
|
+
field :created_at do
|
|
645
|
+
date_format :short
|
|
646
|
+
end
|
|
647
|
+
field :updated_at do
|
|
648
|
+
strftime_format "%Y-%m-%d"
|
|
649
|
+
end
|
|
650
|
+
end
|
|
651
|
+
end
|
|
652
|
+
end
|
|
653
|
+
|
|
654
|
+
This would render all the teams' "created at" dates in the short format of your
|
|
655
|
+
application's locale and "updated at" dates in format YYYY-MM-DD. If both
|
|
656
|
+
options are defined for a single field, `strftime_format` has precedence over
|
|
657
|
+
`date_format` option. For more information about localizing Rails see
|
|
658
|
+
[Rails Internationalization API](http://edgeguides.rubyonrails.org/i18n.html#adding-date-time-formats)
|
|
659
|
+
and [Rails I18n repository](https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale).
|
|
660
|
+
|
|
661
|
+
**Fields - Column CSS class**
|
|
662
|
+
|
|
663
|
+
By default each column has a CSS class set according to field's data type. You
|
|
664
|
+
can customize this by:
|
|
665
|
+
|
|
666
|
+
RailsAdmin.config do |config|
|
|
667
|
+
config.model Team do
|
|
668
|
+
list do
|
|
669
|
+
field :name
|
|
670
|
+
field :created_at do
|
|
671
|
+
css_class "customClass"
|
|
672
|
+
end
|
|
673
|
+
end
|
|
674
|
+
end
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
This would render the "created at" field's header and body columns with a CSS class named
|
|
678
|
+
"customClass".
|
|
679
|
+
|
|
680
|
+
**Fields - Column width**
|
|
681
|
+
|
|
682
|
+
By default columns' widths are calculated from certain pre-defined,
|
|
683
|
+
data-type-specific pixel values. If you want to ensure a minimum width for a
|
|
684
|
+
column, you can:
|
|
685
|
+
|
|
686
|
+
RailsAdmin.config do |config|
|
|
687
|
+
config.model Team do
|
|
688
|
+
list do
|
|
689
|
+
field :name do
|
|
690
|
+
column_width 200
|
|
691
|
+
end
|
|
692
|
+
field :created_at
|
|
693
|
+
end
|
|
694
|
+
end
|
|
695
|
+
end
|
|
696
|
+
|
|
697
|
+
### Create and update views
|
|
698
|
+
|
|
699
|
+
* Form rendering
|
|
700
|
+
* Field groupings
|
|
701
|
+
* Visibility
|
|
702
|
+
* Labels
|
|
703
|
+
* Syntax
|
|
704
|
+
* Fields
|
|
705
|
+
* Rendering
|
|
706
|
+
* Overriding field type
|
|
707
|
+
* Available field types
|
|
708
|
+
* Creating a custom field type
|
|
709
|
+
* Creating a custom field factory
|
|
710
|
+
* Overriding field help texts
|
|
711
|
+
* CKEditor integration
|
|
712
|
+
|
|
713
|
+
**Form rendering**
|
|
714
|
+
|
|
715
|
+
RailsAdmin renders these views with is own form builder: `RailsAdmin::FormBuilder`
|
|
716
|
+
You can inherit from it to customize form output.
|
|
717
|
+
|
|
718
|
+
**Field groupings**
|
|
719
|
+
|
|
720
|
+
By default RailsAdmin groups fields in the edit views (create and update views)
|
|
721
|
+
by including all database columns and belongs to associations to "Basic info"
|
|
722
|
+
group which is displayed on top of form. Below that are displayed all the other
|
|
723
|
+
associations a model has, one group per association.
|
|
724
|
+
|
|
725
|
+
The configuration accessors are `edit`, `create` and `update`. First one is a
|
|
726
|
+
batch accessor which configures both create and update views. For consistency,
|
|
727
|
+
these examples only include the batch accessor `edit`, but if you need differing
|
|
728
|
+
create and update views just replace `edit` with `create` or `update`.
|
|
729
|
+
|
|
730
|
+
**Field groupings - visibility**
|
|
731
|
+
|
|
732
|
+
Field groups can be hidden:
|
|
733
|
+
|
|
734
|
+
RailsAdmin.config do |config|
|
|
735
|
+
config.model Team do
|
|
736
|
+
edit do
|
|
737
|
+
group :default do
|
|
738
|
+
hide
|
|
739
|
+
end
|
|
740
|
+
end
|
|
741
|
+
end
|
|
742
|
+
end
|
|
743
|
+
|
|
744
|
+
This would hide the "Basic info" group which is accessed by the symbol :default.
|
|
745
|
+
Associations' groups can be accessed by the name of the association, such as
|
|
746
|
+
:fans or :players. The hide method is just a shortcut for the actual `visible`
|
|
747
|
+
option which was mentioned in the beginning of the navigation section.
|
|
748
|
+
|
|
749
|
+
**Field groupings - labels**
|
|
750
|
+
|
|
751
|
+
Field groups can be renamed:
|
|
752
|
+
|
|
753
|
+
RailsAdmin.config do |config|
|
|
754
|
+
config.model Team do
|
|
755
|
+
edit do
|
|
756
|
+
group :default do
|
|
757
|
+
label "Team information"
|
|
758
|
+
end
|
|
759
|
+
end
|
|
760
|
+
end
|
|
761
|
+
end
|
|
762
|
+
|
|
763
|
+
This would render "Team information" instead of "Basic info" as the groups label.
|
|
764
|
+
|
|
765
|
+
**Field groupings - help**
|
|
766
|
+
|
|
767
|
+
Field groups can have a set of instructions which is displayed under the label:
|
|
768
|
+
|
|
769
|
+
RailsAdmin.config do |config|
|
|
770
|
+
config.model Team do
|
|
771
|
+
edit do
|
|
772
|
+
group :default do
|
|
773
|
+
label "Team information"
|
|
774
|
+
help "Please fill all informations related to your team..."
|
|
775
|
+
end
|
|
776
|
+
end
|
|
777
|
+
end
|
|
778
|
+
end
|
|
779
|
+
|
|
780
|
+
This content is mostly useful when the admin doign the data entry is not familiar with the system or as a way to display inline documentation.
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
**Field groupings - syntax**
|
|
784
|
+
|
|
785
|
+
As in the list view, the edit views' configuration blocks can directly
|
|
786
|
+
contain field configurations, but in edit views those configurations can
|
|
787
|
+
also be nested within group configurations. Below examples result an
|
|
788
|
+
equal configuration:
|
|
789
|
+
|
|
790
|
+
RailsAdmin.config do |config|
|
|
791
|
+
config.model Team do
|
|
792
|
+
edit do
|
|
793
|
+
group :default do
|
|
794
|
+
label "Default group"
|
|
795
|
+
end
|
|
796
|
+
field :name do
|
|
797
|
+
label "Title"
|
|
798
|
+
group :default
|
|
799
|
+
end
|
|
800
|
+
end
|
|
801
|
+
end
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
RailsAdmin.config do |config|
|
|
805
|
+
config.model Team do
|
|
806
|
+
edit do
|
|
807
|
+
group :default do
|
|
808
|
+
label "Default group"
|
|
809
|
+
field :name do
|
|
810
|
+
label "Title"
|
|
811
|
+
end
|
|
812
|
+
end
|
|
813
|
+
end
|
|
814
|
+
end
|
|
815
|
+
end
|
|
816
|
+
|
|
817
|
+
**Important note on label - I18n**
|
|
818
|
+
|
|
819
|
+
Use association name as translation key for label for association fields.
|
|
820
|
+
If you have :user_id field with a user association, use :user as the attribute
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
In fact the first examples `group :default` configuration is unnecessary
|
|
824
|
+
as the default group has already initialized all fields and belongs to
|
|
825
|
+
associations for itself.
|
|
826
|
+
|
|
827
|
+
**Fields**
|
|
828
|
+
|
|
829
|
+
Just like in the list view, all fields are visible by default. If you specifically
|
|
830
|
+
declare fields, only defined fields will be visible and they will be presented
|
|
831
|
+
in the order defined. Thus both examples would render a form with
|
|
832
|
+
only one group (labeled "Default group") that would contain only one
|
|
833
|
+
element (labeled "Title").
|
|
834
|
+
|
|
835
|
+
In the list view label is the text displayed in the field's column header, but
|
|
836
|
+
in the edit views label literally means the html label element associated with
|
|
837
|
+
field's input element.
|
|
838
|
+
|
|
839
|
+
Naturally edit views' fields also have the visible option along with
|
|
840
|
+
hide and show accessors as the list view has.
|
|
841
|
+
|
|
842
|
+
**Fields - rendering**
|
|
843
|
+
|
|
844
|
+
The edit view's fields are rendered using partials. Each field type has its own
|
|
845
|
+
partial per default, but that can be overridden:
|
|
846
|
+
|
|
847
|
+
RailsAdmin.config do |config|
|
|
848
|
+
config.model Team do
|
|
849
|
+
edit do
|
|
850
|
+
field :name do
|
|
851
|
+
edit_partial "my_awesome_partial"
|
|
852
|
+
end
|
|
853
|
+
end
|
|
854
|
+
end
|
|
855
|
+
end
|
|
856
|
+
|
|
857
|
+
There is a partial method for each action:
|
|
858
|
+
|
|
859
|
+
* edit
|
|
860
|
+
* create
|
|
861
|
+
* update
|
|
862
|
+
|
|
863
|
+
By default, `create` and `update` will render `edit`'s partial.
|
|
864
|
+
|
|
865
|
+
The partial should be placed in your applications template folder, such as
|
|
866
|
+
`app/views/rails_admin/main/_my_awesome_partial.html.erb`.
|
|
867
|
+
|
|
868
|
+
One can also completely override the rendering logic:
|
|
869
|
+
|
|
870
|
+
RailsAdmin.config do |config|
|
|
871
|
+
config.model Team do
|
|
872
|
+
edit do
|
|
873
|
+
field :name do
|
|
874
|
+
render do
|
|
875
|
+
bindings[:view].render :partial => partial.to_s, :locals => {:field => self}
|
|
876
|
+
end
|
|
877
|
+
end
|
|
878
|
+
end
|
|
879
|
+
end
|
|
880
|
+
end
|
|
881
|
+
|
|
882
|
+
That example is just the default rendering method, but it shows you that you
|
|
883
|
+
have access to the current template's scope with bindings[:view]. There's also
|
|
884
|
+
bindings[:object] available, which is the database record being edited.
|
|
885
|
+
Bindings concept was introduced earlier in this document and the
|
|
886
|
+
functionality is the same.
|
|
887
|
+
|
|
888
|
+
Other example of completely override rendering logic is:
|
|
889
|
+
|
|
890
|
+
RailsAdmin.config do |config|
|
|
891
|
+
edit do
|
|
892
|
+
field :published do
|
|
893
|
+
label "Published question?"
|
|
894
|
+
render do
|
|
895
|
+
bindings[:view].render :partial => "yes_no", :locals => {:field => self, :form => bindings[:form], :fieldset => bindings[:fieldset]}
|
|
896
|
+
end
|
|
897
|
+
end
|
|
898
|
+
end
|
|
899
|
+
end
|
|
900
|
+
|
|
901
|
+
In `app/views/rails_admin/main/_yes_no.html.erb`
|
|
902
|
+
|
|
903
|
+
<div class="field <%= field.dom_id %>">
|
|
904
|
+
<%= form.label field.method_name, field.label %>
|
|
905
|
+
<%= form.send :radio_button, field.name, "Y" %>
|
|
906
|
+
|
|
907
|
+
<%= %Q(Yes #{image_tag "yes.png", :alt => "Yes"}      ).html_safe %>
|
|
908
|
+
|
|
909
|
+
<%= form.send :radio_button, field.name, "N" %>
|
|
910
|
+
|
|
911
|
+
<%= %Q(No #{image_tag "no.png", :alt => "No"}).html_safe %>
|
|
912
|
+
|
|
913
|
+
<% if field.errors.present? %>
|
|
914
|
+
<span class="errorMessage"><%= "#{field.label } #{field.errors.first}" %></span>
|
|
915
|
+
<% end %>
|
|
916
|
+
<p class="help"><%= field.help %></p>
|
|
917
|
+
</div>
|
|
918
|
+
|
|
919
|
+
In this *dirty* example above, all objects can be manipulated by the developer.
|
|
920
|
+
|
|
921
|
+
You can flag a field as read only, and if necessary fine-tune the output with pretty_value:
|
|
922
|
+
|
|
923
|
+
RailsAdmin.config do |config|
|
|
924
|
+
edit do
|
|
925
|
+
field :published do
|
|
926
|
+
read_only true
|
|
927
|
+
pretty_value do
|
|
928
|
+
bindings[:object].published? ? 'Yes, it's live!' : 'No, in the loop...'
|
|
929
|
+
end
|
|
930
|
+
end
|
|
931
|
+
end
|
|
932
|
+
end
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
**Fields - overriding field type**
|
|
936
|
+
|
|
937
|
+
If you'd like to override the type of the field that gets instantiated, the
|
|
938
|
+
field method provides second parameter which is field type as a symbol. For
|
|
939
|
+
instance, if we have a column that's a text column in the database, but we'd
|
|
940
|
+
like to have it as a string type we could accomplish that like this:
|
|
941
|
+
|
|
942
|
+
RailsAdmin.config do |config|
|
|
943
|
+
config.model Team do
|
|
944
|
+
edit do
|
|
945
|
+
field :description, :string do
|
|
946
|
+
# configuration here
|
|
947
|
+
end
|
|
948
|
+
end
|
|
949
|
+
end
|
|
950
|
+
end
|
|
951
|
+
|
|
952
|
+
If no configuration needs to take place the configuration block could have been
|
|
953
|
+
left out:
|
|
954
|
+
|
|
955
|
+
RailsAdmin.config do |config|
|
|
956
|
+
config.model Team do
|
|
957
|
+
edit do
|
|
958
|
+
field :description, :string
|
|
959
|
+
end
|
|
960
|
+
end
|
|
961
|
+
end
|
|
962
|
+
|
|
963
|
+
A word of warning, if you make field declarations for the same field a number
|
|
964
|
+
of times with a type defining second argument in place, the type definition
|
|
965
|
+
will ditch the old field configuration and load a new field instance in place.
|
|
966
|
+
|
|
967
|
+
**Fields - Available field types**
|
|
968
|
+
|
|
969
|
+
RailsAdmin ships with the following field types:
|
|
970
|
+
|
|
971
|
+
* belongs_to_association
|
|
972
|
+
* boolean
|
|
973
|
+
* date
|
|
974
|
+
* datetime
|
|
975
|
+
* decimal
|
|
976
|
+
* paperclip/dragonfly/carrierwave *(see Wiki for configuration)*
|
|
977
|
+
* float
|
|
978
|
+
* has_and_belongs_to_many_association
|
|
979
|
+
* has_many_association
|
|
980
|
+
* has_one_association
|
|
981
|
+
* integer
|
|
982
|
+
* password *(initializes if string type column's name is password)*
|
|
983
|
+
* string
|
|
984
|
+
* enum *(see Wiki for configuration)*
|
|
985
|
+
* text
|
|
986
|
+
* time
|
|
987
|
+
* timestamp
|
|
988
|
+
|
|
989
|
+
**Fields - Creating a custom field type**
|
|
990
|
+
|
|
991
|
+
If you have a reusable field you can define a custom class extending
|
|
992
|
+
`RailsAdmin::Config::Fields::Base` and register it for RailsAdmin:
|
|
993
|
+
|
|
994
|
+
RailsAdmin::Config::Fields::Types::register(:my_awesome_type, MyAwesomeFieldClass)
|
|
995
|
+
|
|
996
|
+
Then you can use your custom class in a field:
|
|
997
|
+
|
|
998
|
+
RailsAdmin.config do |config|
|
|
999
|
+
config.model Team do
|
|
1000
|
+
edit do
|
|
1001
|
+
field :name, :my_awesome_type do
|
|
1002
|
+
# configuration here
|
|
1003
|
+
end
|
|
1004
|
+
end
|
|
1005
|
+
end
|
|
1006
|
+
end
|
|
1007
|
+
|
|
1008
|
+
**Fields - Creating a custom field factory**
|
|
1009
|
+
|
|
1010
|
+
Type guessing can be overridden by registering a custom field "factory", but
|
|
1011
|
+
for now you need to study `lib/rails_admin/config/fields/factories/*` for
|
|
1012
|
+
examples if you want to use that mechanism.
|
|
1013
|
+
|
|
1014
|
+
**Fields - Overriding field help texts**
|
|
1015
|
+
|
|
1016
|
+
Every field is accompanied by a hint/text help based on model's validations.
|
|
1017
|
+
Everything can be overridden with `help`:
|
|
1018
|
+
|
|
1019
|
+
RailsAdmin.config do |config|
|
|
1020
|
+
config.model Team do
|
|
1021
|
+
edit do
|
|
1022
|
+
field :name
|
|
1023
|
+
field :email do
|
|
1024
|
+
help 'Required - popular webmail addresses not allowed'
|
|
1025
|
+
end
|
|
1026
|
+
end
|
|
1027
|
+
end
|
|
1028
|
+
end
|
|
1029
|
+
|
|
1030
|
+
**Fields - CKEditor integration**
|
|
1031
|
+
|
|
1032
|
+
CKEditor can be enabled on fields of type text:
|
|
1033
|
+
|
|
1034
|
+
RailsAdmin.config do |config|
|
|
1035
|
+
config.model Team do
|
|
1036
|
+
edit do
|
|
1037
|
+
field :description, :text do
|
|
1038
|
+
ckeditor true
|
|
1039
|
+
end
|
|
1040
|
+
end
|
|
1041
|
+
end
|
|
1042
|
+
end
|
|
1043
|
+
|
|
1044
|
+
**Fields - Ordered has_many/has_and_belongs_to_many/has_many :through associations**
|
|
1045
|
+
|
|
1046
|
+
Orderable can be enabled on filtering multiselect fields (has_many, has_many :through & has_and_belongs_to_many associations),
|
|
1047
|
+
allowing selected options to be moved up/down.
|
|
1048
|
+
RailsAdmin will handle ordering in and out of the form.
|
|
1049
|
+
|
|
1050
|
+
RailsAdmin.config do |config|
|
|
1051
|
+
config.model Player do
|
|
1052
|
+
edit do
|
|
1053
|
+
field :fans do
|
|
1054
|
+
orderable true
|
|
1055
|
+
end
|
|
1056
|
+
end
|
|
1057
|
+
end
|
|
1058
|
+
end
|
|
1059
|
+
|
|
1060
|
+
You'll need to handle ordering in your model with a position column for example.
|
|
1061
|
+
|
|
1062
|
+
** Associations - trivia **
|
|
1063
|
+
|
|
1064
|
+
You can edit related objects in filtering-multiselect by double-clicking on any visible item in the widget.
|
|
1065
|
+
|
|
1066
|
+
If you set the :inverse_of option on your relations, RailsAdmin will automatically populate the inverse relationship
|
|
1067
|
+
in the modal creation window. (link next to belongs\_to and has\_many widgets)
|
|
1068
|
+
|
|
1069
|
+
:readonly options are automatically inferred on associations fields and won't be editable in forms.
|
|
1070
|
+
|
|
1071
|
+
### Configuring fields ###
|
|
1072
|
+
|
|
1073
|
+
* exclude_fields field_list
|
|
1074
|
+
* exclude_fields_if cond
|
|
1075
|
+
* include_fields field_list
|
|
1076
|
+
* include_fields_if cond
|
|
1077
|
+
* include_all_fields
|
|
1078
|
+
* fields field_list, configuration_block
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
** Fields - exclude some fields **
|
|
1082
|
+
|
|
1083
|
+
By default *all* fields found on your model will be added to list/edit/export views,
|
|
1084
|
+
with a few exceptions for polymorphic columns and such.
|
|
1085
|
+
You can exclude specific fields with exclude_fields & exclude_fields_if:
|
|
1086
|
+
|
|
1087
|
+
Example:
|
|
1088
|
+
|
|
1089
|
+
RailsAdmin.config do |config|
|
|
1090
|
+
config.model League do
|
|
1091
|
+
list do
|
|
1092
|
+
exclude_fields_if do
|
|
1093
|
+
type == :datetime
|
|
1094
|
+
end
|
|
1095
|
+
|
|
1096
|
+
exclude_fields :id, :name
|
|
1097
|
+
end
|
|
1098
|
+
end
|
|
1099
|
+
end
|
|
1100
|
+
|
|
1101
|
+
But after you specify your *first* field, this behaviour will be canceled.
|
|
1102
|
+
*Only* the specified fields will be added.
|
|
1103
|
+
But you can then use include_all_fields to add all default fields:
|
|
1104
|
+
|
|
1105
|
+
Example:
|
|
1106
|
+
|
|
1107
|
+
RailsAdmin.config do |config|
|
|
1108
|
+
config.model League do
|
|
1109
|
+
list do
|
|
1110
|
+
field :name do
|
|
1111
|
+
# snipped specific configuration for name attribute
|
|
1112
|
+
end
|
|
1113
|
+
|
|
1114
|
+
include_all_fields # all other default fields will be added after, conveniently
|
|
1115
|
+
exclude_fields :created_at # but you still can remove fields
|
|
1116
|
+
end
|
|
1117
|
+
end
|
|
1118
|
+
end
|
|
1119
|
+
|
|
1120
|
+
** Fields - include some fields **
|
|
1121
|
+
|
|
1122
|
+
It is also possible to add fields by group and configure them by group:
|
|
1123
|
+
|
|
1124
|
+
Example:
|
|
1125
|
+
|
|
1126
|
+
RailsAdmin.config do |config|
|
|
1127
|
+
config.model League do
|
|
1128
|
+
list do
|
|
1129
|
+
# all selected fields will be added, but you can't configure them.
|
|
1130
|
+
# If you need to select them by type, see *fields_of_type*
|
|
1131
|
+
include_fields_if do
|
|
1132
|
+
name =~ /displayed/
|
|
1133
|
+
end
|
|
1134
|
+
|
|
1135
|
+
include_fields :name, :title # simply adding fields by their names (order will be maintained)
|
|
1136
|
+
fields :created_at, :updated_at do # adding and configuring
|
|
1137
|
+
label do
|
|
1138
|
+
"#{label} (timestamp)"
|
|
1139
|
+
end
|
|
1140
|
+
end
|
|
1141
|
+
end
|
|
1142
|
+
end
|
|
1143
|
+
end
|
|
1144
|
+
|
|
1145
|
+
Note that some fields are hidden by default (associations) and that you can display them to the list view by
|
|
1146
|
+
manually setting them to visible:
|
|
1147
|
+
|
|
1148
|
+
RailsAdmin.config do |config|
|
|
1149
|
+
config.model League do
|
|
1150
|
+
list do
|
|
1151
|
+
field :teams do
|
|
1152
|
+
visible true
|
|
1153
|
+
end
|
|
1154
|
+
end
|
|
1155
|
+
end
|
|
1156
|
+
end
|
|
1157
|
+
|
|
1158
|
+
### Mass Assignment Operations ###
|
|
1159
|
+
|
|
1160
|
+
* Mass assign for every model configuration
|
|
1161
|
+
* Mass assign for every section (create, list, navigation and update)
|
|
1162
|
+
* Mass assign by field type
|
|
1163
|
+
|
|
1164
|
+
**Mass assign for every model configuration**
|
|
1165
|
+
|
|
1166
|
+
Mass assignment operations are used to pass in configuration blocks for
|
|
1167
|
+
multiple targets at once. For instance, the code below configures every models'
|
|
1168
|
+
every field with an uppercased label in the list view.
|
|
1169
|
+
|
|
1170
|
+
RailsAdmin.config do |config|
|
|
1171
|
+
config.models do
|
|
1172
|
+
list do
|
|
1173
|
+
fields do
|
|
1174
|
+
label do
|
|
1175
|
+
label.upcase # in this context label refers to default label method
|
|
1176
|
+
end
|
|
1177
|
+
end
|
|
1178
|
+
end
|
|
1179
|
+
end
|
|
1180
|
+
end
|
|
1181
|
+
|
|
1182
|
+
**Mass assign for every section (create, list, navigation and update)**
|
|
1183
|
+
|
|
1184
|
+
If one would like to assign that same behavior for all the different views in
|
|
1185
|
+
RailsAdmin (create, list, navigation and update) one could pass the label
|
|
1186
|
+
definition one level higher:
|
|
1187
|
+
|
|
1188
|
+
RailsAdmin.config do |config|
|
|
1189
|
+
config.models do
|
|
1190
|
+
fields do
|
|
1191
|
+
label do
|
|
1192
|
+
label.upcase
|
|
1193
|
+
end
|
|
1194
|
+
end
|
|
1195
|
+
end
|
|
1196
|
+
end
|
|
1197
|
+
|
|
1198
|
+
As the navigation section does not define the `fields` method this
|
|
1199
|
+
configuration is only effective for create, list and update views.
|
|
1200
|
+
|
|
1201
|
+
Naturally this also works for a single model configuration:
|
|
1202
|
+
|
|
1203
|
+
RailsAdmin.config do |config|
|
|
1204
|
+
config.model Team do
|
|
1205
|
+
fields do
|
|
1206
|
+
label do
|
|
1207
|
+
label.upcase
|
|
1208
|
+
end
|
|
1209
|
+
end
|
|
1210
|
+
end
|
|
1211
|
+
end
|
|
1212
|
+
|
|
1213
|
+
**Mass assign by field type**
|
|
1214
|
+
|
|
1215
|
+
One can also assign configurations for all fields by type. For instance
|
|
1216
|
+
modifying the date presentation of all datetime fields in all sections can be
|
|
1217
|
+
accomplished like this:
|
|
1218
|
+
|
|
1219
|
+
RailsAdmin.config do |config|
|
|
1220
|
+
config.models do
|
|
1221
|
+
fields_of_type :datetime do
|
|
1222
|
+
strftime_format "%Y-%m-%d"
|
|
1223
|
+
end
|
|
1224
|
+
end
|
|
1225
|
+
end
|
|
1226
|
+
|
|
1227
|
+
Or even scope it like this:
|
|
1228
|
+
|
|
1229
|
+
RailsAdmin.config do |config|
|
|
1230
|
+
config.models do
|
|
1231
|
+
list do
|
|
1232
|
+
fields_of_type :datetime do
|
|
1233
|
+
date_format :compact
|
|
1234
|
+
end
|
|
1235
|
+
end
|
|
1236
|
+
end
|
|
1237
|
+
end
|
|
1238
|
+
|
|
1239
|
+
## <a name="authorization">Authorization</a>
|
|
1240
|
+
|
|
1241
|
+
`:attr_accessible` and `:attr_protected` are taken into account: restricted fields are not editable (read_only).
|
|
1242
|
+
If you whitelist attributes, don't forget to whitelist accessible associations' 'id' methods as well : `division_id`, `player_ids`, `commentable_type`, `commentable_id`, etc.
|
|
1243
|
+
`:attr_accessible` specifies a list of accessible methods for mass-assignment in your ActiveModel models. By default, RailsAdmin uses role `:default` (default in ActiveModel).
|
|
1244
|
+
If the role you specify isn't used in your whitelist declarations, you'll free access to all attributes.
|
|
1245
|
+
Keep in mind that `'key' != :key`
|
|
1246
|
+
You can change role with a block evaluated in the context of the controller (you'll have access to the view and your current_user) :
|
|
1247
|
+
|
|
1248
|
+
RailsAdmin.config do |config|
|
|
1249
|
+
config.attr_accessible_role do
|
|
1250
|
+
current_user.roles.first
|
|
1251
|
+
end
|
|
1252
|
+
end
|
|
1253
|
+
|
|
1254
|
+
If you don't want read_only fields to be visible in your forms:
|
|
1255
|
+
|
|
1256
|
+
RailsAdmin.config do |c|
|
|
1257
|
+
c.reload_between_requests = false # strongly advised, since mass-assignement slows things down a lot.
|
|
1258
|
+
c.models do
|
|
1259
|
+
edit do
|
|
1260
|
+
fields do
|
|
1261
|
+
visible do
|
|
1262
|
+
visible && !read_only
|
|
1263
|
+
end
|
|
1264
|
+
end
|
|
1265
|
+
end
|
|
1266
|
+
end
|
|
1267
|
+
end
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
|
|
1271
|
+
Authorization can be added using the `authorize_with` method. If you pass a block
|
|
1272
|
+
it will be triggered through a before filter on every action in Rails Admin.
|
|
1273
|
+
|
|
1274
|
+
RailsAdmin.config do |config|
|
|
1275
|
+
config.authorize_with do
|
|
1276
|
+
redirect_to root_path unless warden.user.is_admin?
|
|
1277
|
+
end
|
|
1278
|
+
end
|
|
1279
|
+
|
|
1280
|
+
To use an authorization adapter, pass the name of the adapter. For example, to use
|
|
1281
|
+
with [CanCan](https://github.com/ryanb/cancan), pass it like this.
|
|
1282
|
+
|
|
1283
|
+
RailsAdmin.config do |config|
|
|
1284
|
+
config.authorize_with :cancan
|
|
1285
|
+
end
|
|
1286
|
+
|
|
1287
|
+
See the [wiki](https://github.com/sferik/rails_admin/wiki) for more on authorization.
|
|
1288
|
+
|
|
1289
|
+
## <a name="contributing">Contributing</a>
|
|
1290
|
+
In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.
|
|
1291
|
+
|
|
1292
|
+
Here are some ways *you* can contribute:
|
|
1293
|
+
|
|
1294
|
+
* by using alpha, beta, and prerelease versions
|
|
1295
|
+
* by reporting bugs
|
|
1296
|
+
* by suggesting new features
|
|
1297
|
+
* by [translating to a new language](https://github.com/sferik/rails_admin/tree/master/config/locales)
|
|
1298
|
+
* by writing or editing documentation
|
|
1299
|
+
* by writing specifications
|
|
1300
|
+
* by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
|
|
1301
|
+
* by refactoring code
|
|
1302
|
+
* by resolving [issues](https://github.com/sferik/rails_admin/issues)
|
|
1303
|
+
* by reviewing patches
|
|
1304
|
+
* [financially](http://pledgie.com/campaigns/15917)
|
|
1305
|
+
|
|
1306
|
+
## <a name="issues">Submitting an Issue</a>
|
|
1307
|
+
We use the [GitHub issue tracker](https://github.com/sferik/rails_admin/issues) to track bugs and
|
|
1308
|
+
features. Before submitting a bug report or feature request, check to make sure it hasn't already
|
|
1309
|
+
been submitted. You can indicate support for an existing issue by voting it up. When submitting a
|
|
1310
|
+
bug report, please include a [Gist](https://gist.github.com/) that includes a stack trace and any
|
|
1311
|
+
details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
|
|
1312
|
+
operating system. Ideally, a bug report should include a pull request with failing specs.
|
|
1313
|
+
|
|
1314
|
+
## <a name="pulls">Submitting a Pull Request</a>
|
|
1315
|
+
1. Fork the project.
|
|
1316
|
+
2. Create a topic branch.
|
|
1317
|
+
3. Implement your feature or bug fix. *NOTE* - there's a small test app located in the spec/dummy_app directory that you can use to experiment with rails_admin.
|
|
1318
|
+
4. Add documentation for your feature or bug fix.
|
|
1319
|
+
5. Run `bundle exec rake doc:yard`. If your changes are not 100% documented, go back to step 4.
|
|
1320
|
+
6. Add specs for your feature or bug fix.
|
|
1321
|
+
7. Run `bundle exec rake spec`. If your changes are not 100% covered, go back to step 6.
|
|
1322
|
+
8. Commit and push your changes.
|
|
1323
|
+
9. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
|
|
1324
|
+
|
|
1325
|
+
## <a name="rubies">Supported Rubies</a>
|
|
1326
|
+
This library aims to support and is [tested
|
|
1327
|
+
against](http://travis-ci.org/sferik/rails_admin) the following Ruby
|
|
1328
|
+
implementations:
|
|
1329
|
+
|
|
1330
|
+
* Ruby 1.8.7
|
|
1331
|
+
* [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
|
|
1332
|
+
* Ruby 1.9.2
|
|
1333
|
+
* Ruby 1.9.3
|
|
1334
|
+
* [Rubinius](http://rubini.us)
|