activeadmin 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- data/.gitignore +5 -1
- data/.travis.yml +1 -1
- data/.yardopts +2 -3
- data/CHANGELOG.md +180 -36
- data/CONTRIBUTING.md +12 -2
- data/Gemfile +9 -3
- data/README.rdoc +38 -65
- data/Rakefile +1 -3
- data/activeadmin.gemspec +10 -11
- data/app/assets/images/active_admin/index_list_icons/block_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/blog_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/grid_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/table_icon.svg +1 -1
- data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/lib/namespace.js.coffee +2 -1
- data/app/assets/javascripts/active_admin/pages/application.js.coffee +6 -1
- data/app/assets/stylesheets/active_admin/_base.css.scss +29 -34
- data/app/assets/stylesheets/active_admin/_forms.css.scss +65 -62
- data/app/assets/stylesheets/active_admin/_header.css.scss +57 -45
- data/app/assets/stylesheets/active_admin/_typography.css.scss +9 -9
- data/app/assets/stylesheets/active_admin/components/_batch_actions.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +5 -5
- data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_comments.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_date_picker.css.scss +20 -20
- data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +16 -16
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +25 -23
- data/app/assets/stylesheets/active_admin/components/_grid.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_index_list.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +10 -10
- data/app/assets/stylesheets/active_admin/components/_panels.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +27 -27
- data/app/assets/stylesheets/active_admin/components/_scopes.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +10 -10
- data/app/assets/stylesheets/active_admin/components/_tables.css.scss +9 -9
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +3 -3
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +4 -4
- data/app/assets/stylesheets/active_admin/mixins/_icons.css.scss +4 -7
- data/app/assets/stylesheets/active_admin/mixins/_reset.css.scss +5 -5
- data/app/assets/stylesheets/active_admin/mixins/_rounded.css.scss +3 -3
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +6 -6
- data/app/assets/stylesheets/active_admin/mixins/_shadows.css.scss +8 -8
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_utilities.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +9 -1
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +1 -1
- data/app/assets/stylesheets/active_admin/print.css.scss +2 -8
- data/app/assets/stylesheets/active_admin/structure/_footer.scss +5 -5
- data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +13 -13
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +14 -14
- data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
- data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
- data/app/views/active_admin/devise/shared/_links.erb +8 -1
- data/app/views/active_admin/resource/index.csv.erb +3 -3
- data/app/views/layouts/active_admin_logged_out.html.erb +5 -3
- data/config/locales/bg.yml +101 -0
- data/{lib/active_admin → config}/locales/ca.yml +24 -7
- data/{lib/active_admin → config}/locales/cs.yml +34 -12
- data/{lib/active_admin → config}/locales/da.yml +29 -7
- data/config/locales/de-CH.yml +117 -0
- data/{lib/active_admin → config}/locales/de.yml +19 -9
- data/config/locales/en-GB.yml +90 -0
- data/{lib/active_admin → config}/locales/en.yml +16 -6
- data/config/locales/es.yml +106 -0
- data/{lib/active_admin/locales/es.yml → config/locales/es_MX.yml} +14 -8
- data/{lib/active_admin → config}/locales/fr.yml +14 -6
- data/{lib/active_admin → config}/locales/he.yml +16 -6
- data/{lib/active_admin → config}/locales/hr.yml +14 -6
- data/{lib/active_admin → config}/locales/hu.yml +31 -6
- data/{lib/active_admin → config}/locales/it.yml +14 -6
- data/{lib/active_admin → config}/locales/ja.yml +32 -7
- data/{lib/active_admin → config}/locales/ko.yml +14 -6
- data/{lib/active_admin → config}/locales/lt.yml +15 -6
- data/{lib/active_admin → config}/locales/lv.yml +14 -6
- data/{lib/active_admin → config}/locales/nl.yml +14 -6
- data/{lib/active_admin → config}/locales/no-NB.yml +14 -6
- data/{lib/active_admin → config}/locales/pl.yml +14 -6
- data/{lib/active_admin → config}/locales/pt-BR.yml +14 -6
- data/{lib/active_admin → config}/locales/pt-PT.yml +14 -6
- data/{lib/active_admin → config}/locales/ro.yml +32 -7
- data/{lib/active_admin → config}/locales/ru.yml +30 -8
- data/{lib/active_admin → config}/locales/sv-SE.yml +14 -6
- data/{lib/active_admin → config}/locales/tr.yml +15 -6
- data/config/locales/uk.yml +100 -0
- data/{lib/active_admin → config}/locales/vi.yml +15 -6
- data/{lib/active_admin → config}/locales/zh-CN.yml +15 -6
- data/{lib/active_admin → config}/locales/zh-TW.yml +15 -6
- data/docs/0-installation.md +22 -18
- data/docs/1-general-configuration.md +1 -1
- data/docs/10-custom-pages.md +3 -3
- data/docs/11-decorators.md +18 -2
- data/docs/12-arbre-components.md +53 -54
- data/docs/13-authorization-adapter.md +31 -10
- data/docs/2-resource-customization.md +16 -1
- data/docs/3-index-pages.md +13 -1
- data/docs/3-index-pages/create-an-index.md +4 -4
- data/docs/3-index-pages/index-as-block.md +1 -1
- data/docs/3-index-pages/index-as-blog.md +1 -1
- data/docs/3-index-pages/index-as-grid.md +1 -1
- data/docs/4-csv-format.md +4 -4
- data/docs/5-forms.md +46 -3
- data/docs/{6-show-screens.md → 6-show-pages.md} +3 -3
- data/docs/8-custom-actions.md +3 -3
- data/docs/9-batch-actions.md +9 -1
- data/features/action_item.feature +6 -6
- data/features/authorization_cancan.feature +1 -1
- data/features/belongs_to.feature +3 -3
- data/features/breadcrumb.feature +2 -2
- data/features/comments/commenting.feature +7 -5
- data/features/dashboard.feature +0 -51
- data/features/favicon.feature +20 -0
- data/features/global_navigation.feature +0 -1
- data/features/index/batch_actions.feature +12 -11
- data/features/index/filters.feature +6 -6
- data/features/index/format_as_csv.feature +4 -5
- data/features/index/index_as_blog.feature +20 -1
- data/features/index/index_as_table.feature +1 -1
- data/features/index/index_blank_slate.feature +3 -3
- data/features/index/index_parameters.feature +4 -10
- data/features/index/index_scope_to.feature +24 -0
- data/features/index/index_scopes.feature +17 -5
- data/features/index/pagination.feature +15 -0
- data/features/registering_pages.feature +1 -1
- data/features/registering_resources.feature +2 -2
- data/features/show/default_content.feature +3 -3
- data/features/sidebar_sections.feature +3 -3
- data/features/specifying_actions.feature +1 -1
- data/features/step_definitions/additional_web_steps.rb +3 -16
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/attribute_steps.rb +4 -4
- data/features/step_definitions/batch_action_steps.rb +25 -74
- data/features/step_definitions/breadcrumb_steps.rb +1 -3
- data/features/step_definitions/comment_steps.rb +0 -1
- data/features/step_definitions/configuration_steps.rb +53 -69
- data/features/step_definitions/dashboard_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +17 -33
- data/features/step_definitions/filter_steps.rb +2 -2
- data/features/step_definitions/format_steps.rb +10 -14
- data/features/step_definitions/index_scope_steps.rb +9 -25
- data/features/step_definitions/index_views_steps.rb +1 -1
- data/features/step_definitions/sidebar_steps.rb +2 -1
- data/features/step_definitions/site_title_steps.rb +1 -1
- data/features/step_definitions/table_steps.rb +6 -1
- data/features/step_definitions/user_steps.rb +23 -38
- data/features/step_definitions/web_steps.rb +18 -147
- data/features/support/env.rb +13 -34
- data/features/support/paths.rb +2 -0
- data/features/users/logging_in.feature +2 -2
- data/features/users/logging_out.feature +0 -12
- data/features/users/resetting_password.feature +1 -1
- data/lib/active_admin.rb +4 -17
- data/lib/active_admin/abstract_view_factory.rb +1 -1
- data/lib/active_admin/application.rb +19 -28
- data/lib/active_admin/asset_registration.rb +7 -25
- data/lib/active_admin/authorization_adapter.rb +9 -5
- data/lib/active_admin/base_controller.rb +2 -2
- data/lib/active_admin/base_controller/authorization.rb +25 -27
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -3
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -1
- data/lib/active_admin/batch_actions/views/selection_cells.rb +1 -1
- data/lib/active_admin/callbacks.rb +1 -1
- data/lib/active_admin/cancan_adapter.rb +2 -2
- data/lib/active_admin/comments.rb +32 -38
- data/lib/active_admin/comments/comment.rb +6 -8
- data/lib/active_admin/comments/views.rb +0 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +27 -38
- data/lib/active_admin/csv_builder.rb +4 -6
- data/lib/active_admin/dependency_checker.rb +4 -0
- data/lib/active_admin/deprecation.rb +3 -3
- data/lib/active_admin/dsl.rb +5 -5
- data/lib/active_admin/engine.rb +1 -1
- data/lib/active_admin/filters.rb +2 -1
- data/lib/active_admin/filters/forms.rb +36 -43
- data/lib/active_admin/filters/formtastic_addons.rb +45 -0
- data/lib/active_admin/filters/resource_extension.rb +9 -1
- data/lib/active_admin/form_builder.rb +30 -19
- data/lib/active_admin/helpers/optional_display.rb +11 -13
- data/lib/active_admin/helpers/settings.rb +50 -8
- data/lib/active_admin/inputs/filter_base.rb +5 -18
- data/lib/active_admin/inputs/filter_base/search_method_select.rb +73 -0
- data/lib/active_admin/inputs/filter_boolean_input.rb +6 -14
- data/lib/active_admin/inputs/filter_check_boxes_input.rb +1 -1
- data/lib/active_admin/inputs/filter_numeric_input.rb +2 -47
- data/lib/active_admin/inputs/filter_select_input.rb +32 -10
- data/lib/active_admin/inputs/filter_string_input.rb +12 -14
- data/lib/active_admin/namespace.rb +8 -40
- data/lib/active_admin/page.rb +2 -2
- data/lib/active_admin/page_dsl.rb +1 -1
- data/lib/active_admin/reloader.rb +3 -3
- data/lib/active_admin/resource.rb +16 -23
- data/lib/active_admin/resource/belongs_to.rb +8 -5
- data/lib/active_admin/resource/menu.rb +10 -23
- data/lib/active_admin/resource/naming.rb +3 -3
- data/lib/active_admin/resource/page_presenters.rb +2 -2
- data/lib/active_admin/resource/routes.rb +74 -21
- data/lib/active_admin/resource/scope_to.rb +74 -0
- data/lib/active_admin/resource/scopes.rb +8 -4
- data/lib/active_admin/resource_collection.rb +20 -66
- data/lib/active_admin/resource_controller.rb +12 -16
- data/lib/active_admin/resource_controller/data_access.rb +19 -22
- data/lib/active_admin/resource_controller/resource_class_methods.rb +2 -2
- data/lib/active_admin/resource_controller/scoping.rb +4 -9
- data/lib/active_admin/resource_dsl.rb +5 -32
- data/lib/active_admin/router.rb +34 -47
- data/lib/active_admin/scope.rb +5 -3
- data/lib/active_admin/sidebar_section.rb +1 -1
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +1 -1
- data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +8 -8
- data/lib/active_admin/view_helpers/display_helper.rb +15 -6
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +2 -2
- data/lib/active_admin/view_helpers/form_helper.rb +6 -1
- data/lib/active_admin/view_helpers/icon_helper.rb +1 -1
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +5 -5
- data/lib/active_admin/view_helpers/title_helper.rb +1 -1
- data/lib/active_admin/views/components/action_list_popover.rb +6 -6
- data/lib/active_admin/views/components/attributes_table.rb +9 -12
- data/lib/active_admin/views/components/blank_slate.rb +4 -4
- data/lib/active_admin/views/components/columns.rb +1 -1
- data/lib/active_admin/views/components/index_list.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +20 -12
- data/lib/active_admin/views/components/panel.rb +1 -1
- data/lib/active_admin/views/components/scopes.rb +2 -1
- data/lib/active_admin/views/components/sidebar_section.rb +1 -1
- data/lib/active_admin/views/components/status_tag.rb +1 -1
- data/lib/active_admin/views/header.rb +2 -2
- data/lib/active_admin/views/index_as_blog.rb +16 -3
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/base.rb +8 -3
- data/lib/active_admin/views/pages/form.rb +2 -2
- data/lib/active_admin/views/pages/index.rb +19 -17
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +1 -1
- data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +1 -13
- data/lib/generators/active_admin/devise/devise_generator.rb +22 -1
- data/lib/generators/active_admin/install/install_generator.rb +1 -5
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +40 -19
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +18 -18
- data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb +19 -0
- data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
- data/lib/generators/active_admin/resource/templates/admin.rb +1 -1
- data/script/use_rails +1 -1
- data/spec/integration/memory_spec.rb +3 -2
- data/spec/javascripts/coffeescripts/jquery.aa.checkbox-toggler-spec.js.coffee +4 -4
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +1 -1
- data/spec/javascripts/coffeescripts/jquery.aa.table-checkbox-toggler-spec.js.coffee +2 -2
- data/spec/javascripts/compiled/jquery.aa.checkbox-toggler-spec.js +4 -4
- data/spec/javascripts/compiled/jquery.aa.popover-spec.js +1 -1
- data/spec/javascripts/compiled/jquery.aa.table-checkbox-toggler-spec.js +2 -2
- data/spec/spec_helper.rb +16 -6
- data/spec/spec_helper_without_rails.rb +2 -0
- data/spec/support/deferred_garbage_collection.rb +19 -0
- data/spec/support/jslint.yml +1 -1
- data/spec/support/rails_template.rb +29 -27
- data/spec/support/templates/admin/stores.rb +5 -1
- data/spec/unit/abstract_view_factory_spec.rb +1 -1
- data/spec/unit/action_builder_spec.rb +7 -7
- data/spec/unit/active_admin_spec.rb +0 -14
- data/spec/unit/application_spec.rb +16 -17
- data/spec/unit/asset_registration_spec.rb +21 -8
- data/spec/unit/authorization/authorization_adapter_spec.rb +3 -3
- data/spec/unit/authorization/controller_authorization_spec.rb +16 -24
- data/spec/unit/batch_actions/resource_spec.rb +11 -11
- data/spec/unit/belongs_to_spec.rb +1 -1
- data/spec/unit/cancan_adapter_spec.rb +11 -3
- data/spec/unit/comments_spec.rb +10 -28
- data/spec/unit/controller_filters_spec.rb +22 -24
- data/spec/unit/csv_builder_spec.rb +3 -3
- data/spec/unit/devise_spec.rb +10 -10
- data/spec/unit/filters/filter_form_builder_spec.rb +140 -45
- data/spec/unit/filters/resource_spec.rb +20 -19
- data/spec/unit/form_builder_spec.rb +122 -70
- data/spec/unit/menu_item_spec.rb +3 -3
- data/spec/unit/namespace/authorization_spec.rb +4 -8
- data/spec/unit/namespace/register_page_spec.rb +1 -1
- data/spec/unit/namespace/register_resource_spec.rb +12 -7
- data/spec/unit/namespace_spec.rb +4 -10
- data/spec/unit/page_spec.rb +1 -1
- data/spec/unit/resource/menu_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +9 -0
- data/spec/unit/resource/pagination_spec.rb +2 -2
- data/spec/unit/resource/routes_spec.rb +73 -0
- data/spec/unit/resource/scopes_spec.rb +1 -1
- data/spec/unit/resource_collection_spec.rb +95 -43
- data/spec/unit/resource_registration_spec.rb +3 -12
- data/spec/unit/resource_spec.rb +41 -48
- data/spec/unit/routing_spec.rb +10 -64
- data/spec/unit/scope_spec.rb +19 -0
- data/spec/unit/settings_spec.rb +88 -0
- data/spec/unit/view_factory_spec.rb +1 -0
- data/spec/unit/{breadcrumbs_spec.rb → view_helpers/breadcrumbs_spec.rb} +16 -7
- data/spec/unit/view_helpers/display_name_spec.rb +41 -0
- data/spec/unit/view_helpers/form_helper_spec.rb +36 -2
- data/spec/unit/views/components/attributes_table_spec.rb +17 -9
- data/spec/unit/views/components/batch_action_popover_spec.rb +4 -4
- data/spec/unit/views/components/index_list_spec.rb +2 -2
- data/spec/unit/views/components/paginated_collection_spec.rb +42 -0
- data/spec/unit/views/components/panel_spec.rb +8 -0
- data/spec/unit/views/components/site_title_spec.rb +2 -2
- data/spec/unit/views/components/table_for_spec.rb +4 -4
- data/spec/unit/views/pages/form_spec.rb +35 -0
- data/spec/unit/views/pages/layout_spec.rb +1 -1
- data/spec/unit/views/tabbed_navigation_spec.rb +10 -10
- data/tasks/parallel_tests.rake +1 -1
- data/tasks/test.rake +4 -1
- metadata +117 -106
- data/app/assets/stylesheets/active_admin/pages/_dashboard.scss +0 -5
- data/lib/active_admin/comments/views/active_admin_comment.rb +0 -0
- data/lib/active_admin/dashboards.rb +0 -68
- data/lib/active_admin/dashboards/dashboard_controller.rb +0 -50
- data/lib/active_admin/dashboards/section.rb +0 -34
- data/lib/active_admin/locales/bg.yml +0 -77
- data/lib/generators/active_admin/install/templates/migrations/1_create_admin_notes.rb +0 -17
- data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +0 -26
- data/spec/unit/base_controller_spec.rb +0 -6
- data/spec/unit/dashboard_controller_spec.rb +0 -76
- data/spec/unit/dashboard_section_spec.rb +0 -56
- data/spec/unit/dashboards_spec.rb +0 -59
- data/spec/unit/display_name_spec.rb +0 -29
@@ -1,13 +1,13 @@
|
|
1
1
|
# Authorization Adapter
|
2
2
|
|
3
|
-
Active Admin offers the ability to define and use your own authorization
|
4
|
-
adapter. If implemented, the '#authorized?' will be called when an action is
|
3
|
+
Active Admin offers the ability to define and use your own authorization
|
4
|
+
adapter. If implemented, the '#authorized?' will be called when an action is
|
5
5
|
taken. By default, '#authorized?' returns true.
|
6
6
|
|
7
7
|
|
8
8
|
## Setting up your own AuthorizationAdapter
|
9
9
|
|
10
|
-
Setting up your own `AuthorizationAdapter` is easy! The following example shows
|
10
|
+
Setting up your own `AuthorizationAdapter` is easy! The following example shows
|
11
11
|
how to set up and tie your authorization adapter class to Active Admin:
|
12
12
|
|
13
13
|
# app/models/only_authors_authorization.rb
|
@@ -15,7 +15,7 @@ how to set up and tie your authorization adapter class to Active Admin:
|
|
15
15
|
|
16
16
|
def authorized?(action, subject = nil)
|
17
17
|
case subject
|
18
|
-
when
|
18
|
+
when normalized(Post)
|
19
19
|
|
20
20
|
# Only let the author update and delete posts
|
21
21
|
if action == :update || action == :destroy
|
@@ -33,7 +33,7 @@ how to set up and tie your authorization adapter class to Active Admin:
|
|
33
33
|
|
34
34
|
end
|
35
35
|
|
36
|
-
In order to hook up `OnlyAuthorsAuthorization` to Active Admin, go to your
|
36
|
+
In order to hook up `OnlyAuthorsAuthorization` to Active Admin, go to your
|
37
37
|
application's `config/initializers/active_admin.rb` and add/modify the line:
|
38
38
|
|
39
39
|
config.authorization_adapter = "OnlyAuthorsAuthorization"
|
@@ -55,7 +55,7 @@ Now, whenever a controller action is performed, the `OnlyAuthorsAuthorization`'s
|
|
55
55
|
|
56
56
|
## Getting Access to the Current User
|
57
57
|
|
58
|
-
From within your authorization adapter, you can call the `#user` method to
|
58
|
+
From within your authorization adapter, you can call the `#user` method to
|
59
59
|
retrieve the current user.
|
60
60
|
|
61
61
|
class OnlyAdmins < ActiveAdmin::AuthorizationAdapter
|
@@ -69,8 +69,8 @@ retrieve the current user.
|
|
69
69
|
|
70
70
|
## Scoping Collections in Authorization Adapters
|
71
71
|
|
72
|
-
`ActiveAdmin::AuthorizationAdapter` also provides a hook method (`#scope_collection`)
|
73
|
-
for the adapter to scope the resource's collection. For example, you may want to
|
72
|
+
`ActiveAdmin::AuthorizationAdapter` also provides a hook method (`#scope_collection`)
|
73
|
+
for the adapter to scope the resource's collection. For example, you may want to
|
74
74
|
centralize the scoping:
|
75
75
|
|
76
76
|
class OnlyMyAccount < ActiveAdmin::AuthorizationAdapter
|
@@ -112,7 +112,7 @@ subject will be an instance of `ActiveAdmin::Page`.
|
|
112
112
|
|
113
113
|
## Action Types
|
114
114
|
|
115
|
-
By default Active Admin simplifies the controller actions into 4 actions:
|
115
|
+
By default Active Admin simplifies the controller actions into 4 actions:
|
116
116
|
|
117
117
|
* `:read` - This controls if the user can view the menu item as well as the
|
118
118
|
index and show screens.
|
@@ -181,6 +181,27 @@ To use the CanCan adapter, simply update the configuration in the Active Admin
|
|
181
181
|
initializer:
|
182
182
|
|
183
183
|
config.authorization_adapter = ActiveAdmin::CanCanAdapter
|
184
|
+
|
185
|
+
You can also specify a method to be called on unauthorized access. This is necessary
|
186
|
+
in order to prevent a redirect loop that can happen if a user tries to access a page
|
187
|
+
they don't have permissions for (see [#2081](https://github.com/gregbell/active_admin/issues/2081)).
|
188
|
+
```ruby
|
189
|
+
config.on_unauthorized_access = :access_denied
|
190
|
+
```
|
191
|
+
The method `access_denied` would be defined in `application_controller.rb`. Here is one
|
192
|
+
example that redirects the user from the page they don't have permission to
|
193
|
+
access to a resource they have permission to access (organizations in this case), and
|
194
|
+
also displays the error message in the browser:
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
class ApplicationController < ActionController::Base
|
198
|
+
protect_from_forgery
|
199
|
+
|
200
|
+
def access_denied(exception)
|
201
|
+
redirect_to admin_organizations_path, :alert => exception.message
|
202
|
+
end
|
203
|
+
end
|
204
|
+
```
|
184
205
|
|
185
206
|
By default this will use the ability class named "Ability". This can also be
|
186
207
|
changed from the initializer:
|
@@ -194,7 +215,7 @@ will use it for authorization:
|
|
194
215
|
class Ability
|
195
216
|
include CanCan::Ability
|
196
217
|
|
197
|
-
def
|
218
|
+
def initialize(user)
|
198
219
|
can :manage, Post
|
199
220
|
can :read, User
|
200
221
|
can :manage, User, :id => user.id
|
@@ -158,6 +158,21 @@ has_many relationships, you can simply scope the listings and finders like so:
|
|
158
158
|
|
159
159
|
That approach limits the posts an admin can access to ```current_user.posts```.
|
160
160
|
|
161
|
+
If you want to conditionally apply the scope, then there are options for that as well:
|
162
|
+
|
163
|
+
ActiveAdmin.register Post do
|
164
|
+
# Only scope the query if there is a user to scope to, helper provided via Devise
|
165
|
+
scope_to :current_user, :if => proc{ admin_user_signed_in? }
|
166
|
+
|
167
|
+
# Don't scope the query if the user is an admin
|
168
|
+
scope_to :current_user, :unless => proc{ current_admin_user.admin? }
|
169
|
+
|
170
|
+
# Get fancy and can combine with block syntax
|
171
|
+
scope_to :if => proc{ admin_user_signed_in? } do
|
172
|
+
User.most_popular
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
161
176
|
If you want to do something fancier, for example override a default scope, you can
|
162
177
|
also use :association_method parameter with a normal method on your User model.
|
163
178
|
The only requirement is that your method returns an instance of ActiveRecord::Relation.
|
@@ -229,7 +244,7 @@ possibilities for how you may with to handle your user interface):
|
|
229
244
|
|
230
245
|
ActiveAdmin.register Project do
|
231
246
|
|
232
|
-
sidebar "Project Details" do
|
247
|
+
sidebar "Project Details", only: [:show, :edit] do
|
233
248
|
ul do
|
234
249
|
li link_to("Tickets", admin_project_tickets_path(project))
|
235
250
|
li link_to("Milestones", admin_project_milestones_path(project))
|
data/docs/3-index-pages.md
CHANGED
@@ -50,7 +50,7 @@ class of the index component you created.
|
|
50
50
|
index :as => ActiveAdmin::Views::IndexAsTable do
|
51
51
|
column :image_title
|
52
52
|
default_actions
|
53
|
-
end
|
53
|
+
end
|
54
54
|
|
55
55
|
## Index Filters
|
56
56
|
|
@@ -143,6 +143,17 @@ You can also disable pagination:
|
|
143
143
|
config.paginate = false
|
144
144
|
end
|
145
145
|
|
146
|
+
If you have a very large database, you might want to disable SELECT COUNT(*) queries caused by the pagination info at the bottom of the page:
|
147
|
+
|
148
|
+
ActiveAdmin.register Post do
|
149
|
+
|
150
|
+
# disable pagination total
|
151
|
+
index :pagination_total => false do
|
152
|
+
#...
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
|
146
157
|
## Disable CSV, XML and JSON export
|
147
158
|
|
148
159
|
You can remove links to download CSV, XML and JSON exports:
|
@@ -177,3 +188,4 @@ If you want to customize download links for every resource throughout the applic
|
|
177
188
|
config.download_links = [:csv, :xml, :json, :pdf]
|
178
189
|
|
179
190
|
end
|
191
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Create an Index
|
2
2
|
|
3
3
|
If the supplied Active Admin index components are insufficient for your project
|
4
|
-
feel free to define your own. Index classes extend ActiveAdmin::Component and
|
4
|
+
feel free to define your own. Index classes extend ActiveAdmin::Component and
|
5
5
|
require a build method and an index_name class method.
|
6
6
|
|
7
7
|
module ActiveAdmin
|
@@ -20,10 +20,10 @@ require a build method and an index_name class method.
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
The build method takes a PagePresenter object and collection of whatever you
|
23
|
+
The build method takes a PagePresenter object and collection of whatever you
|
24
24
|
choose.
|
25
25
|
|
26
26
|
The index_name class method takes no arguments and returns a string that should
|
27
27
|
be representative of the the class name. If this method is not defined, your
|
28
|
-
index component will not be able take advantage of Active Admin's
|
29
|
-
*multiple index pages* feature.
|
28
|
+
index component will not be able take advantage of Active Admin's
|
29
|
+
*multiple index pages* feature.
|
data/docs/4-csv-format.md
CHANGED
@@ -16,7 +16,7 @@ Customizing the CSV format is as simple as customizing the index page.
|
|
16
16
|
You can set custom csv options:
|
17
17
|
|
18
18
|
ActiveAdmin.register Post do
|
19
|
-
csv :
|
19
|
+
csv :force_quotes => true do
|
20
20
|
column :title
|
21
21
|
column("Author") { |post| post.author.full_name }
|
22
22
|
end
|
@@ -25,8 +25,8 @@ You can set custom csv options:
|
|
25
25
|
You can set options for the CSV format system-wide:
|
26
26
|
|
27
27
|
# config/initializers/active_admin.rb
|
28
|
-
# Set the CSV builder separator
|
29
|
-
config.
|
28
|
+
# Set the CSV builder separator
|
29
|
+
config.csv_options = { :col_sep => ';' }
|
30
30
|
|
31
|
-
#
|
31
|
+
# Force the use of quotes
|
32
32
|
config.csv_options = { :force_quotes => true }
|
data/docs/5-forms.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Customizing the Form
|
2
2
|
|
3
3
|
Active Admin gives complete control over the output of the form by creating a thin DSL on top of
|
4
|
-
the fabulous DSL created by Formtastic
|
4
|
+
the fabulous DSL created by [Formtastic](http://github.com/justinfrench/formtastic).
|
5
5
|
|
6
6
|
ActiveAdmin.register Post do
|
7
7
|
|
@@ -19,8 +19,8 @@ the fabulous DSL created by Formtastic (http://github.com/justinfrench/formtasti
|
|
19
19
|
|
20
20
|
end
|
21
21
|
|
22
|
-
Please view the documentation
|
23
|
-
|
22
|
+
Please view [the documentation](http://github.com/justinfrench/formtastic)
|
23
|
+
for Formtastic to see all the wonderful things you can do.
|
24
24
|
|
25
25
|
If you require a more custom form than can be provided through the DSL, you can pass
|
26
26
|
a partial in to render the form yourself.
|
@@ -37,3 +37,46 @@ Then implement app/views/admin/posts/_form.html.erb:
|
|
37
37
|
<%= f.inputs :title, :body %>
|
38
38
|
<%= f.actions :commit %>
|
39
39
|
<% end %>
|
40
|
+
|
41
|
+
## Nested Resources
|
42
|
+
|
43
|
+
You can create forms with nested models using the `has_many` method:
|
44
|
+
|
45
|
+
ActiveAdmin.register Post do
|
46
|
+
|
47
|
+
form do |f|
|
48
|
+
f.inputs "Details" do
|
49
|
+
f.input :title
|
50
|
+
f.input :published_at, :label => "Publish Post At"
|
51
|
+
end
|
52
|
+
f.inputs "Content" do
|
53
|
+
f.input :body
|
54
|
+
end
|
55
|
+
f.inputs do
|
56
|
+
f.has_many :categories, :allow_destroy => true, :heading => 'Themes', :new_record => false do |cf|
|
57
|
+
cf.input :title
|
58
|
+
end
|
59
|
+
end
|
60
|
+
f.actions
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
The `:allow_destroy` option will add a checkbox to the end of the nested form allowing
|
66
|
+
removal of the child object upon submission. Be sure to set `:allow_destroy => true`
|
67
|
+
on the association to use this option.
|
68
|
+
|
69
|
+
The `:heading` option will add a custom heading to has_many form. You can hide a heading by setting `:heading => false`.
|
70
|
+
|
71
|
+
The `:new_record` option will show or hide new record link at the bottom of has_many form. It is set as true by default.
|
72
|
+
|
73
|
+
## Displaying Errors
|
74
|
+
|
75
|
+
To display a list of all errors, include `semantic_errors` at top of form. Particularly useful to display errors on the base or virtual attributes.
|
76
|
+
|
77
|
+
form do |f|
|
78
|
+
f.semantic_errors *f.object.errors.keys
|
79
|
+
f.inputs
|
80
|
+
f.buttons
|
81
|
+
end
|
82
|
+
|
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Customize the Show Page
|
2
2
|
|
3
|
-
|
3
|
+
Customize the show page is as simple as implementing the show block:
|
4
4
|
|
5
5
|
ActiveAdmin.register Post do
|
6
6
|
show do
|
@@ -36,7 +36,7 @@ If you'd like to keep the default active_admin look, you can also use "attribute
|
|
36
36
|
end
|
37
37
|
|
38
38
|
You can customize the title of the object in the show screen. The default is the resource name and the ID. You can customize as follows:
|
39
|
-
|
39
|
+
|
40
40
|
show :title => :name do
|
41
41
|
end
|
42
42
|
|
data/docs/8-custom-actions.md
CHANGED
@@ -56,7 +56,7 @@ your action will use the :get verb.
|
|
56
56
|
## Rendering in Custom Actions
|
57
57
|
|
58
58
|
Custom controller actions support rendering within the standard Active Admin
|
59
|
-
layout.
|
59
|
+
layout.
|
60
60
|
|
61
61
|
ActiveAdmin.register Post do
|
62
62
|
|
@@ -81,10 +81,10 @@ For example, create app/views/admin/posts/comments.html.arb with:
|
|
81
81
|
simple_format comment.body
|
82
82
|
end
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
### Custom Action Items
|
86
86
|
|
87
|
-
To include your own action items (like the New, Edit and Delete buttons), add an
|
87
|
+
To include your own action items (like the New, Edit and Delete buttons), add an
|
88
88
|
`action_item` block. For example, to add a "View on site" button to view a blog
|
89
89
|
post:
|
90
90
|
|
data/docs/9-batch-actions.md
CHANGED
@@ -105,7 +105,7 @@ Can be translated with:
|
|
105
105
|
labels:
|
106
106
|
publish: "Publish"
|
107
107
|
|
108
|
-
### Batch Action Confirmation
|
108
|
+
### Batch Action Confirmation
|
109
109
|
|
110
110
|
You can also request that the user confirm the action, before the action is performed:
|
111
111
|
|
@@ -159,3 +159,11 @@ You can easily use `batch_action` in the other index views, *Grid*, *Block*, and
|
|
159
159
|
end
|
160
160
|
|
161
161
|
end
|
162
|
+
|
163
|
+
### Batch Actions and Custom Actions
|
164
|
+
|
165
|
+
In order to perform the batch action, the entire *Table*, *Grid*, etc. is wrapped in a form that submits the id's of the selected rows to your batch_action.
|
166
|
+
|
167
|
+
Since nested `<form>` tags in HTML often results in unexpected behavior, you may need to modify custom actions or forms you are using on your page with batch actions enabled.
|
168
|
+
|
169
|
+
Specifically, if you are using HTTP methods like `PUT` or `PATCH` with a custom form on your index page this may result in your batch action being `PUT`ed instead of `POST`ed which in turn will create a routing error. You can get around this by either moving the nested form to another page (ie. the Object's show page) or, if possible, changing the method of the custom action to `POST` so that it doesn't override the batch action. Remember, behavior may vary by browser.
|
@@ -10,9 +10,9 @@ Feature: Action Item
|
|
10
10
|
Given a configuration of:
|
11
11
|
"""
|
12
12
|
ActiveAdmin.register Post do
|
13
|
-
action_item do
|
13
|
+
action_item do
|
14
14
|
link_to "Embiggen", '/'
|
15
|
-
end
|
15
|
+
end
|
16
16
|
end
|
17
17
|
"""
|
18
18
|
When I am on the index page for posts
|
@@ -32,9 +32,9 @@ Feature: Action Item
|
|
32
32
|
Given a configuration of:
|
33
33
|
"""
|
34
34
|
ActiveAdmin.register Post do
|
35
|
-
action_item :if => proc{ !current_active_admin_user.nil? } do
|
35
|
+
action_item :if => proc{ !current_active_admin_user.nil? } do
|
36
36
|
link_to "Embiggen", '/'
|
37
|
-
end
|
37
|
+
end
|
38
38
|
end
|
39
39
|
"""
|
40
40
|
When I am on the index page for posts
|
@@ -54,9 +54,9 @@ Feature: Action Item
|
|
54
54
|
Given a configuration of:
|
55
55
|
"""
|
56
56
|
ActiveAdmin.register Post do
|
57
|
-
action_item :if => proc{ current_active_admin_user.nil? } do
|
57
|
+
action_item :if => proc{ current_active_admin_user.nil? } do
|
58
58
|
link_to "Embiggen", '/'
|
59
|
-
end
|
59
|
+
end
|
60
60
|
end
|
61
61
|
"""
|
62
62
|
When I am on the index page for posts
|
data/features/belongs_to.feature
CHANGED
@@ -16,8 +16,8 @@ Feature: Belongs To
|
|
16
16
|
end
|
17
17
|
"""
|
18
18
|
When I go to the last author's posts
|
19
|
-
Then the "
|
20
|
-
And I should not see a menu item for "
|
19
|
+
Then the "Posts" tab should be selected
|
20
|
+
And I should not see a menu item for "Users"
|
21
21
|
And I should see "Displaying 1 Post"
|
22
22
|
And I should see a link to "Users" in the breadcrumb
|
23
23
|
|
@@ -32,7 +32,7 @@ Feature: Belongs To
|
|
32
32
|
When I go to the last author's posts
|
33
33
|
And I follow "View"
|
34
34
|
Then I should be on the last author's last post page
|
35
|
-
And the "
|
35
|
+
And the "Posts" tab should be selected
|
36
36
|
|
37
37
|
Scenario: When the belongs to is optional
|
38
38
|
Given a configuration of:
|
data/features/breadcrumb.feature
CHANGED
@@ -11,7 +11,7 @@ Feature: Breadcrumb
|
|
11
11
|
"""
|
12
12
|
When I am on the new post page
|
13
13
|
Then I should see a link to "Post" in the breadcrumb
|
14
|
-
|
14
|
+
|
15
15
|
Scenario: Rewritten breadcrumb links
|
16
16
|
Given a configuration of:
|
17
17
|
"""
|
@@ -24,4 +24,4 @@ Feature: Breadcrumb
|
|
24
24
|
end
|
25
25
|
"""
|
26
26
|
When I am on the new post page
|
27
|
-
Then I should see a link to "test" in the breadcrumb
|
27
|
+
Then I should see a link to "test" in the breadcrumb
|
@@ -34,13 +34,14 @@ Feature: Commenting
|
|
34
34
|
config.comments = false
|
35
35
|
end
|
36
36
|
"""
|
37
|
-
Then I should not see "
|
37
|
+
Then I should not see the element "div.comments.panel"
|
38
38
|
|
39
39
|
Scenario: View a resource in a namespace that doesn't have comments
|
40
40
|
Given a configuration of:
|
41
41
|
"""
|
42
|
-
|
43
|
-
|
42
|
+
ActiveAdmin.application.namespace(:new_namespace).allow_comments = false
|
43
|
+
ActiveAdmin.register Post, :namespace => :new_namespace
|
44
|
+
ActiveAdmin.register AdminUser, :namespace => :new_namespace
|
44
45
|
"""
|
45
46
|
Given I am logged in
|
46
47
|
When I am on the index page for posts in the new_namespace namespace
|
@@ -51,7 +52,8 @@ Feature: Commenting
|
|
51
52
|
Given a show configuration of:
|
52
53
|
"""
|
53
54
|
ActiveAdmin.register Post
|
54
|
-
ActiveAdmin.register Post,
|
55
|
+
ActiveAdmin.register Post, :namespace => :public
|
56
|
+
ActiveAdmin.register AdminUser, :namespace => :public
|
55
57
|
"""
|
56
58
|
When I add a comment "Hello world in admin namespace"
|
57
59
|
Then I should see "Hello world in admin namespace"
|
@@ -123,4 +125,4 @@ Feature: Commenting
|
|
123
125
|
And I follow "View"
|
124
126
|
When I add a comment "Tag Comment"
|
125
127
|
Then I should see a flash with "Comment was successfully created"
|
126
|
-
And I should be in the resource section for tags
|
128
|
+
And I should be in the resource section for tags
|