activeadmin 1.0.0.pre4 → 1.0.0.pre5
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -3
- data/.travis.yml +48 -26
- data/Appraisals +103 -0
- data/CHANGELOG.md +12 -1
- data/CONTRIBUTING.md +85 -32
- data/Gemfile +13 -38
- data/README.md +10 -26
- data/Rakefile +41 -9
- data/activeadmin.gemspec +7 -4
- data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +10 -3
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -4
- data/app/assets/javascripts/active_admin/lib/checkbox-toggler.js.coffee +8 -0
- data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +14 -3
- data/app/assets/stylesheets/active_admin/_forms.scss +1 -0
- data/app/views/active_admin/devise/registrations/new.html.erb +1 -1
- data/codecov.yml +23 -0
- data/config/locales/es-MX.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/config/locales/ru.yml +1 -0
- data/config/locales/sk.yml +110 -0
- data/docs/0-installation.md +3 -0
- data/docs/1-general-configuration.md +11 -0
- data/docs/10-custom-pages.md +25 -0
- data/docs/11-decorators.md +3 -0
- data/docs/12-arbre-components.md +3 -0
- data/docs/13-authorization-adapter.md +3 -0
- data/docs/14-gotchas.md +19 -0
- data/docs/2-resource-customization.md +21 -2
- data/docs/3-index-pages.md +21 -0
- data/docs/3-index-pages/custom-index.md +3 -0
- data/docs/3-index-pages/index-as-block.md +3 -0
- data/docs/3-index-pages/index-as-blog.md +3 -0
- data/docs/3-index-pages/index-as-grid.md +3 -0
- data/docs/3-index-pages/index-as-table.md +22 -0
- data/docs/4-csv-format.md +15 -0
- data/docs/5-forms.md +7 -3
- data/docs/6-show-pages.md +3 -0
- data/docs/7-sidebars.md +3 -0
- data/docs/8-custom-actions.md +3 -0
- data/docs/9-batch-actions.md +4 -1
- data/docs/CNAME +1 -0
- data/docs/Gemfile +2 -0
- data/docs/_config.yml +2 -0
- data/docs/_includes/footer.html +8 -0
- data/docs/_includes/google-analytics.html +16 -0
- data/docs/_includes/head.html +7 -0
- data/docs/_includes/toc.html +97 -0
- data/docs/_includes/top-menu.html +9 -0
- data/docs/_layouts/default.html +21 -0
- data/docs/documentation.md +62 -0
- data/docs/images/activeadmin.png +0 -0
- data/docs/images/code-header.png +0 -0
- data/docs/images/divider.png +0 -0
- data/docs/images/features.png +0 -0
- data/docs/index.html +130 -0
- data/docs/stylesheets/main.css +1199 -0
- data/features/action_item.feature +2 -2
- data/features/authorization_cancan.feature +3 -3
- data/features/belongs_to.feature +60 -2
- data/features/comments/commenting.feature +7 -7
- data/features/development_reloading.feature +1 -1
- data/features/edit_page.feature +9 -9
- data/features/footer.feature +28 -0
- data/features/i18n.feature +11 -0
- data/features/index/batch_actions.feature +28 -6
- data/features/index/filters.feature +31 -11
- data/features/index/format_as_csv.feature +13 -13
- data/features/index/formats.feature +4 -4
- data/features/index/index_as_block.feature +1 -1
- data/features/index/index_as_blog.feature +6 -6
- data/features/index/index_as_grid.feature +3 -3
- data/features/index/index_as_table.feature +11 -11
- data/features/index/index_blank_slate.feature +4 -4
- data/features/index/index_parameters.feature +10 -10
- data/features/index/index_scope_to.feature +3 -3
- data/features/index/index_scopes.feature +37 -18
- data/features/index/page_title.feature +3 -3
- data/features/index/pagination.feature +1 -1
- data/features/index/switch_index_view.feature +8 -8
- data/features/menu.feature +3 -3
- data/features/new_page.feature +8 -8
- data/features/registering_assets.feature +1 -1
- data/features/registering_pages.feature +73 -2
- data/features/registering_resources.feature +1 -1
- data/features/renamed_resource.feature +1 -1
- data/features/show/page_title.feature +3 -3
- data/features/sidebar_sections.feature +6 -6
- data/features/specifying_actions.feature +29 -4
- data/features/step_definitions/factory_steps.rb +1 -1
- data/features/step_definitions/footer_steps.rb +11 -0
- data/features/step_definitions/i18n_steps.rb +8 -0
- data/features/step_definitions/index_scope_steps.rb +4 -0
- data/features/step_definitions/sidebar_steps.rb +1 -3
- data/features/step_definitions/table_steps.rb +1 -5
- data/features/step_definitions/user_steps.rb +7 -0
- data/features/support/env.rb +6 -33
- data/features/support/paths.rb +5 -0
- data/features/users/logging_in.feature +2 -0
- data/gemfiles/rails_32.gemfile +54 -0
- data/gemfiles/rails_40.gemfile +53 -0
- data/gemfiles/rails_41.gemfile +53 -0
- data/gemfiles/rails_42.gemfile +53 -0
- data/gemfiles/rails_50.gemfile +46 -0
- data/lib/active_admin.rb +1 -0
- data/lib/active_admin/application.rb +11 -0
- data/lib/active_admin/batch_actions/resource_extension.rb +0 -8
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -1
- data/lib/active_admin/dsl.rb +0 -6
- data/lib/active_admin/filters/active.rb +9 -1
- data/lib/active_admin/filters/formtastic_addons.rb +1 -1
- data/lib/active_admin/filters/humanized.rb +1 -1
- data/lib/active_admin/filters/resource_extension.rb +2 -4
- data/lib/active_admin/form_builder.rb +12 -6
- data/lib/active_admin/helpers/collection.rb +2 -0
- data/lib/active_admin/inputs.rb +1 -0
- data/lib/active_admin/inputs/filters/date_range_input.rb +9 -4
- data/lib/active_admin/inputs/filters/text_input.rb +26 -0
- data/lib/active_admin/localizers.rb +11 -0
- data/lib/active_admin/localizers/resource_localizer.rb +35 -0
- data/lib/active_admin/namespace.rb +1 -1
- data/lib/active_admin/order_clause.rb +29 -7
- data/lib/active_admin/page.rb +18 -4
- data/lib/active_admin/page_dsl.rb +4 -0
- data/lib/active_admin/resource.rb +16 -1
- data/lib/active_admin/resource/action_items.rb +7 -4
- data/lib/active_admin/resource/belongs_to.rb +4 -0
- data/lib/active_admin/resource/menu.rb +1 -1
- data/lib/active_admin/resource/ordering.rb +11 -0
- data/lib/active_admin/resource/routes.rb +34 -13
- data/lib/active_admin/resource/scopes.rb +1 -0
- data/lib/active_admin/resource_controller/data_access.rb +3 -10
- data/lib/active_admin/resource_dsl.rb +28 -1
- data/lib/active_admin/router.rb +5 -3
- data/lib/active_admin/scope.rb +3 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -2
- data/lib/active_admin/view_helpers/display_helper.rb +8 -3
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +5 -1
- data/lib/active_admin/views/components/active_admin_form.rb +11 -10
- data/lib/active_admin/views/components/attributes_table.rb +1 -1
- data/lib/active_admin/views/components/columns.rb +3 -3
- data/lib/active_admin/views/components/dropdown_menu.rb +2 -2
- data/lib/active_admin/views/components/index_list.rb +4 -1
- data/lib/active_admin/views/components/paginated_collection.rb +1 -0
- data/lib/active_admin/views/components/scopes.rb +8 -1
- data/lib/active_admin/views/components/site_title.rb +2 -2
- data/lib/active_admin/views/components/table_for.rb +3 -3
- data/lib/active_admin/views/footer.rb +17 -3
- data/lib/active_admin/views/index_as_table.rb +3 -3
- data/lib/active_admin/views/pages/base.rb +4 -2
- data/lib/active_admin/views/pages/form.rb +2 -3
- data/lib/active_admin/views/pages/show.rb +2 -1
- data/lib/bug_report_templates/rails_5_master.rb +120 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +6 -3
- data/lib/generators/active_admin/install/install_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +15 -1
- data/lib/generators/active_admin/install/templates/migrations/{create_active_admin_comments.rb → create_active_admin_comments.rb.erb} +14 -1
- data/lib/ransack_ext.rb +2 -2
- data/spec/bug_report_templates_spec.rb +27 -0
- data/spec/javascripts/support/jasmine_runner.rb +4 -17
- data/spec/rails_helper.rb +20 -109
- data/spec/requests/default_namespace_spec.rb +16 -28
- data/spec/requests/javascript_spec.rb +1 -1
- data/spec/requests/memory_spec.rb +5 -1
- data/spec/requests/stylesheets_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -10
- data/spec/support/active_admin_integration_spec_helper.rb +66 -0
- data/spec/support/active_admin_request_helpers.rb +12 -0
- data/spec/support/rails_template.rb +42 -15
- data/spec/support/rails_template_with_data.rb +24 -5
- data/spec/support/templates/manifest.js +3 -0
- data/spec/support/templates/policies/application_policy.rb +1 -1
- data/spec/unit/abstract_view_factory_spec.rb +1 -1
- data/spec/unit/action_builder_spec.rb +3 -12
- data/spec/unit/active_admin_spec.rb +1 -1
- data/spec/unit/application_spec.rb +5 -1
- data/spec/unit/asset_registration_spec.rb +1 -1
- data/spec/unit/authorization/authorization_adapter_spec.rb +1 -1
- data/spec/unit/authorization/controller_authorization_spec.rb +13 -9
- data/spec/unit/authorization/index_overriding_spec.rb +6 -6
- data/spec/unit/auto_link_spec.rb +48 -24
- data/spec/unit/batch_actions/resource_spec.rb +1 -14
- data/spec/unit/batch_actions/settings_spec.rb +1 -1
- data/spec/unit/belongs_to_spec.rb +9 -1
- data/spec/unit/cancan_adapter_spec.rb +1 -1
- data/spec/unit/comments_spec.rb +26 -19
- data/spec/unit/component_spec.rb +1 -1
- data/spec/unit/config_shared_examples.rb +1 -1
- data/spec/unit/controller_filters_spec.rb +1 -1
- data/spec/unit/csv_builder_spec.rb +5 -5
- data/spec/unit/dependency_spec.rb +1 -1
- data/spec/unit/devise_spec.rb +17 -3
- data/spec/unit/dsl_spec.rb +2 -2
- data/spec/unit/filters/active_spec.rb +21 -0
- data/spec/unit/filters/filter_form_builder_spec.rb +98 -31
- data/spec/unit/filters/humanized_spec.rb +9 -1
- data/spec/unit/filters/resource_spec.rb +5 -4
- data/spec/unit/form_builder_spec.rb +180 -33
- data/spec/unit/generators/install_spec.rb +12 -5
- data/spec/unit/helpers/collection_spec.rb +10 -7
- data/spec/unit/helpers/scope_chain_spec.rb +1 -1
- data/spec/unit/helpers/settings_spec.rb +1 -1
- data/spec/unit/i18n_spec.rb +1 -1
- data/spec/unit/localizers/resource_localizer_spec.rb +36 -0
- data/spec/unit/menu_collection_spec.rb +1 -1
- data/spec/unit/menu_item_spec.rb +1 -1
- data/spec/unit/menu_spec.rb +1 -1
- data/spec/unit/namespace/authorization_spec.rb +1 -1
- data/spec/unit/namespace/register_page_spec.rb +28 -2
- data/spec/unit/namespace/register_resource_spec.rb +3 -1
- data/spec/unit/namespace_spec.rb +23 -1
- data/spec/unit/order_clause_spec.rb +7 -7
- data/spec/unit/page_controller_spec.rb +1 -1
- data/spec/unit/page_spec.rb +55 -2
- data/spec/unit/pretty_format_spec.rb +8 -7
- data/spec/unit/pundit_adapter_spec.rb +1 -1
- data/spec/unit/resource/action_items_spec.rb +1 -1
- data/spec/unit/resource/includes_spec.rb +1 -1
- data/spec/unit/resource/menu_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +1 -1
- data/spec/unit/resource/ordering_spec.rb +38 -0
- data/spec/unit/resource/page_presenters_spec.rb +1 -1
- data/spec/unit/resource/pagination_spec.rb +1 -1
- data/spec/unit/resource/routes_spec.rb +101 -53
- data/spec/unit/resource/scopes_spec.rb +1 -1
- data/spec/unit/resource/sidebars_spec.rb +1 -1
- data/spec/unit/resource_collection_spec.rb +1 -1
- data/spec/unit/resource_controller/data_access_spec.rb +50 -1
- data/spec/unit/resource_controller/decorators_spec.rb +2 -2
- data/spec/unit/resource_controller/sidebars_spec.rb +16 -17
- data/spec/unit/resource_controller_spec.rb +50 -56
- data/spec/unit/resource_registration_spec.rb +9 -4
- data/spec/unit/resource_spec.rb +9 -1
- data/spec/unit/routing_spec.rb +30 -2
- data/spec/unit/scope_spec.rb +26 -2
- data/spec/unit/settings_spec.rb +2 -2
- data/spec/unit/view_factory_spec.rb +1 -1
- data/spec/unit/view_helpers/breadcrumbs_spec.rb +1 -1
- data/spec/unit/view_helpers/display_helper_spec.rb +18 -3
- data/spec/unit/view_helpers/download_format_links_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/fields_for_spec.rb +1 -1
- data/spec/unit/view_helpers/flash_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/form_helper_spec.rb +1 -1
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +1 -1
- data/spec/unit/views/components/attributes_table_spec.rb +1 -1
- data/spec/unit/views/components/batch_action_selector_spec.rb +1 -1
- data/spec/unit/views/components/blank_slate_spec.rb +1 -1
- data/spec/unit/views/components/columns_spec.rb +1 -1
- data/spec/unit/views/components/index_list_spec.rb +18 -4
- data/spec/unit/views/components/index_table_for_spec.rb +1 -1
- data/spec/unit/views/components/paginated_collection_spec.rb +1 -1
- data/spec/unit/views/components/panel_spec.rb +1 -1
- data/spec/unit/views/components/sidebar_section_spec.rb +1 -1
- data/spec/unit/views/components/site_title_spec.rb +1 -1
- data/spec/unit/views/components/status_tag_spec.rb +1 -1
- data/spec/unit/views/components/table_for_spec.rb +9 -7
- data/spec/unit/views/components/tabs_spec.rb +1 -1
- data/spec/unit/views/components/unsupported_browser_spec.rb +3 -3
- data/spec/unit/views/index_as_blog_spec.rb +1 -1
- data/spec/unit/views/pages/form_spec.rb +1 -1
- data/spec/unit/views/pages/index_spec.rb +1 -1
- data/spec/unit/views/pages/layout_spec.rb +1 -1
- data/spec/unit/views/pages/show_spec.rb +1 -1
- data/spec/unit/views/tabbed_navigation_spec.rb +2 -2
- data/tasks/local.rake +25 -0
- data/tasks/parallel_tests.rake +4 -4
- data/tasks/test.rake +8 -53
- metadata +61 -18
- data/Guardfile +0 -8
- data/script/local +0 -53
- data/script/travis_cache +0 -107
- data/script/use_rails +0 -53
- data/spec/javascripts/support/jasmine_config.rb +0 -23
- data/spec/support/detect_rails_version.rb +0 -34
data/docs/0-installation.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
---
|
2
|
+
redirect_from: /docs/1-general-configuration.html
|
3
|
+
---
|
1
4
|
# General Configuration
|
2
5
|
|
3
6
|
You can configure Active Admin settings in `config/initializers/active_admin.rb`.
|
@@ -169,3 +172,11 @@ ActiveAdmin.setup do |config|
|
|
169
172
|
end
|
170
173
|
end
|
171
174
|
```
|
175
|
+
|
176
|
+
## Footer Customization
|
177
|
+
|
178
|
+
By default, Active Admin displays a "Powered by ActiveAdmin" message on every
|
179
|
+
page. You can override this message and show domain-specific messaging:
|
180
|
+
```ruby
|
181
|
+
config.footer = "MyApp Revision v1.3"
|
182
|
+
```
|
data/docs/10-custom-pages.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
---
|
2
|
+
redirect_from: /docs/10-custom-pages.html
|
3
|
+
---
|
1
4
|
# Custom Pages
|
2
5
|
|
3
6
|
If you have data you want on a standalone page that isn't tied to a resource,
|
@@ -71,6 +74,19 @@ ActiveAdmin.register_page "Calendar", namespace: :today
|
|
71
74
|
ActiveAdmin.register_page "Calendar", namespace: false
|
72
75
|
```
|
73
76
|
|
77
|
+
## Belongs To
|
78
|
+
|
79
|
+
To nest the page within another resource, you can use the `belongs_to` method:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
ActiveAdmin.register Project
|
83
|
+
ActiveAdmin.register_page "Status" do
|
84
|
+
belongs_to :project
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
See also the [Belongs To](2-resource-customization.md#belongs-to) documentation and examples.
|
89
|
+
|
74
90
|
## Add a Sidebar
|
75
91
|
|
76
92
|
See the [Sidebars](7-sidebars.md) documentation.
|
@@ -104,3 +120,12 @@ end
|
|
104
120
|
This defines the route `/admin/calendar/add_event` which can handle HTTP POST requests.
|
105
121
|
|
106
122
|
Clicking on the action item will reload page and display the message "Your event was added"
|
123
|
+
|
124
|
+
Page actions can handle multiple HTTP verbs.
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
page_action :add_event, method: [:get, :post] do
|
128
|
+
# ...
|
129
|
+
end
|
130
|
+
```
|
131
|
+
See also the [Custom Actions](8-custom-actions.md#http-verbs) example.
|
data/docs/11-decorators.md
CHANGED
data/docs/12-arbre-components.md
CHANGED
data/docs/14-gotchas.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
---
|
2
|
+
redirect_from: /docs/14-gotchas.html
|
3
|
+
---
|
1
4
|
#Gotchas
|
2
5
|
|
3
6
|
## Security
|
@@ -95,6 +98,22 @@ YourModel.__elasticsearch__.search
|
|
95
98
|
```ruby
|
96
99
|
YourModel.solr_search
|
97
100
|
```
|
101
|
+
|
102
|
+
### Rails 5 scaffold generators
|
103
|
+
|
104
|
+
Active Admin requires the `inherited_resources` gem which may break scaffolding under Rails 5 as it replaces the default scaffold generator. The solution is to configure the default controller in `config/application.rb` as outlined in [josevalim/inherited_resources#195](https://github.com/josevalim/inherited_resources/issues/195)
|
105
|
+
|
106
|
+
```
|
107
|
+
module SampleApp
|
108
|
+
class Application < Rails::Application
|
109
|
+
...
|
110
|
+
config.app_generators.scaffold_controller = :scaffold_controller
|
111
|
+
...
|
112
|
+
end
|
113
|
+
end
|
114
|
+
```
|
115
|
+
|
116
|
+
|
98
117
|
## Authentication & Application Controller
|
99
118
|
|
100
119
|
The `ActiveAdmin::BaseController` inherits from the `ApplicationController`. Any authentication method(s) specified in the `ApplicationController` callbacks will be called instead of the authentication method in the active admin config file. For example, if the ApplicationController has a callback `before_action :custom_authentication_method` and the config file's authentication method is `config.authentication_method = :authenticate_active_admin_user`, then `custom_authentication_method` will be called instead of `authenticate_active_admin_user`.
|
@@ -1,3 +1,6 @@
|
|
1
|
+
---
|
2
|
+
redirect_from: /docs/2-resource-customization.html
|
3
|
+
---
|
1
4
|
# Working with Resources
|
2
5
|
|
3
6
|
Every Active Admin resource corresponds to a Rails model. So before creating a
|
@@ -65,6 +68,15 @@ ActiveAdmin.register Post do
|
|
65
68
|
end
|
66
69
|
```
|
67
70
|
|
71
|
+
If your resource is nested, declare `permit_params` after `belongs_to`:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
ActiveAdmin.register Post do
|
75
|
+
belongs_to :user
|
76
|
+
permit_params :title, :content, :publisher_id
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
68
80
|
The `permit_params` call creates a method called `permitted_params`. You should use this method when overriding `create` or `update` actions:
|
69
81
|
|
70
82
|
```ruby
|
@@ -94,6 +106,13 @@ ActiveAdmin.register Post do
|
|
94
106
|
end
|
95
107
|
```
|
96
108
|
|
109
|
+
## Renaming Action Items
|
110
|
+
|
111
|
+
One can set custom button name and page title for new, edit, and destroy actions/pages
|
112
|
+
at the resource level by providing a resource specific translation.
|
113
|
+
For example to change 'New Offer' to 'Make an Offer'
|
114
|
+
set `active_admin.resources.offer.new_model`.
|
115
|
+
|
97
116
|
## Rename the Resource
|
98
117
|
|
99
118
|
By default, any references to the resource (menu, routes, buttons, etc) in the
|
@@ -364,8 +383,8 @@ ActiveAdmin.register Project do
|
|
364
383
|
|
365
384
|
sidebar "Project Details", only: [:show, :edit] do
|
366
385
|
ul do
|
367
|
-
li link_to "Tickets", admin_project_tickets_path(
|
368
|
-
li link_to "Milestones", admin_project_milestones_path(
|
386
|
+
li link_to "Tickets", admin_project_tickets_path(resource)
|
387
|
+
li link_to "Milestones", admin_project_milestones_path(resource)
|
369
388
|
end
|
370
389
|
end
|
371
390
|
end
|
data/docs/3-index-pages.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
---
|
2
|
+
redirect_from: /docs/3-index-pages.html
|
3
|
+
---
|
1
4
|
# Customizing the Index Page
|
2
5
|
|
3
6
|
Filtering and listing resources is one of the most important tasks for
|
@@ -100,6 +103,22 @@ the collection as a proc to be called at render time.
|
|
100
103
|
filter :author, as: :check_boxes, collection: proc { Author.all }
|
101
104
|
```
|
102
105
|
|
106
|
+
To override options for string or numeric filter pass `filters` option.
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
filter :title, filters: [:starts_with, :ends_with]
|
110
|
+
```
|
111
|
+
|
112
|
+
Also, if you don't need the select with the options 'contains', 'equals', 'starts_with' or 'ends_with'
|
113
|
+
just add the option to the filter name with an underscore.
|
114
|
+
|
115
|
+
For example:
|
116
|
+
```ruby
|
117
|
+
filter :name_equals
|
118
|
+
# or
|
119
|
+
filter :name_contains
|
120
|
+
```
|
121
|
+
|
103
122
|
You can change the filter label by passing a label option:
|
104
123
|
|
105
124
|
```ruby
|
@@ -186,6 +205,8 @@ scope "Published", if: proc { current_admin_user.can? :manage, Posts } do |posts
|
|
186
205
|
end
|
187
206
|
```
|
188
207
|
|
208
|
+
Scopes can be labelled with a translation, e.g. `activerecord.scopes.invoice.expired`.
|
209
|
+
|
189
210
|
## Index default sort order
|
190
211
|
|
191
212
|
You can define the default sort order for index pages:
|
@@ -1,3 +1,6 @@
|
|
1
|
+
---
|
2
|
+
redirect_from: /docs/3-index-pages/index-as-table.html
|
3
|
+
---
|
1
4
|
<!--
|
2
5
|
WARNING: Please DO NOT edit this file! Update
|
3
6
|
source documentation in lib/active_admin/views
|
@@ -164,6 +167,24 @@ index do
|
|
164
167
|
end
|
165
168
|
```
|
166
169
|
|
170
|
+
## Custom sorting
|
171
|
+
|
172
|
+
It is also possible to use database specific expressions and options for sorting by column
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
order_by(:title) do |order_clause|
|
176
|
+
if order_clause.order == 'desc'
|
177
|
+
[order_clause.to_sql, 'NULLS LAST'].join(' ')
|
178
|
+
else
|
179
|
+
[order_clause.to_sql, 'NULLS FIRST'].join(' ')
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
index do
|
184
|
+
column :title
|
185
|
+
end
|
186
|
+
```
|
187
|
+
|
167
188
|
## Associated Sorting
|
168
189
|
|
169
190
|
You're normally able to sort columns alphabetically, but by default you
|
@@ -187,6 +208,7 @@ index do
|
|
187
208
|
end
|
188
209
|
```
|
189
210
|
|
211
|
+
|
190
212
|
## Showing and Hiding Columns
|
191
213
|
|
192
214
|
The entire index block is rendered within the context of the view, so you can
|
data/docs/4-csv-format.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
---
|
2
|
+
redirect_from: /docs/4-csv-format.html
|
3
|
+
---
|
1
4
|
# Customizing the CSV format
|
2
5
|
|
3
6
|
Active Admin provides CSV file downloads on the index screen for each Resource.
|
@@ -39,6 +42,18 @@ config.csv_options = { col_sep: ';' }
|
|
39
42
|
config.csv_options = { force_quotes: true }
|
40
43
|
```
|
41
44
|
|
45
|
+
You can customize the filename by overriding `csv_filename` in the controller block.
|
46
|
+
```ruby
|
47
|
+
ActiveAdmin.register User do
|
48
|
+
controller do
|
49
|
+
def csv_filename
|
50
|
+
'User Details.csv'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
|
42
57
|
## Streaming
|
43
58
|
|
44
59
|
By default Active Admin streams the CSV response to your browser as it's generated.
|
data/docs/5-forms.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
---
|
2
|
+
redirect_from: /docs/5-forms.html
|
3
|
+
---
|
1
4
|
# Forms
|
2
5
|
|
3
6
|
Active Admin gives you complete control over the output of the form by creating
|
@@ -96,7 +99,8 @@ ActiveAdmin.register Post do
|
|
96
99
|
end
|
97
100
|
end
|
98
101
|
f.inputs do
|
99
|
-
f.has_many :comment, new_record: 'Leave Comment'
|
102
|
+
f.has_many :comment, new_record: 'Leave Comment',
|
103
|
+
allow_destroy: proc { |comment| comment.author?(current_admin_user) } do |b|
|
100
104
|
b.input :body
|
101
105
|
end
|
102
106
|
end
|
@@ -108,14 +112,14 @@ end
|
|
108
112
|
|
109
113
|
The `:allow_destroy` option adds a checkbox to the end of the nested form allowing
|
110
114
|
removal of the child object upon submission. Be sure to set `allow_destroy: true`
|
111
|
-
on the association to use this option.
|
115
|
+
on the association to use this option. It is possible to associate `:allow_destroy` with a string or a symbol, corresponding to the name of a child object's method that will get called, or with a Proc object. The Proc object receives the child object as a parameter and should return either true or false.
|
112
116
|
|
113
117
|
The `:heading` option adds a custom heading. You can hide it entirely by passing `false`.
|
114
118
|
|
115
119
|
The `:new_record` option controls the visibility of the new record button (shown by default).
|
116
120
|
If you pass a string, it will be used as the text for the new record button.
|
117
121
|
|
118
|
-
The `:sortable` option adds a hidden field and will enable drag & drop sorting of the children. It
|
122
|
+
The `:sortable` option adds a hidden field and will enable drag & drop sorting of the children. It
|
119
123
|
expects the name of the column that will store the index of each child.
|
120
124
|
|
121
125
|
The `:sortable_start` option sets the value (0 by default) of the first position in the list.
|
data/docs/6-show-pages.md
CHANGED
data/docs/7-sidebars.md
CHANGED
data/docs/8-custom-actions.md
CHANGED
data/docs/9-batch-actions.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
---
|
2
|
+
redirect_from: /docs/9-batch-actions.html
|
3
|
+
---
|
1
4
|
# Batch Actions
|
2
5
|
|
3
6
|
By default, the index page provides you a "Batch Action" to quickly delete records,
|
@@ -145,7 +148,7 @@ When you have dynamic form inputs you can pass a proc instead:
|
|
145
148
|
|
146
149
|
```ruby
|
147
150
|
# NOTE: multi-pluck is new to Rails 4
|
148
|
-
batch_action :doit, form: ->{{user: User.pluck(:name, :id)}} do |ids, inputs|
|
151
|
+
batch_action :doit, form: -> { {user: User.pluck(:name, :id)} } do |ids, inputs|
|
149
152
|
User.find(inputs[:user])
|
150
153
|
# ...
|
151
154
|
end
|
data/docs/CNAME
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
activeadmin.info
|
data/docs/Gemfile
ADDED
data/docs/_config.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<p id="footer">
|
2
|
+
<div class="left">
|
3
|
+
Copyright 2011 <a href="http://gregbell.ca/">Greg Bell</a> and <a href="http://www.versapay.com/">VersaPay</a>
|
4
|
+
</div>
|
5
|
+
<div class="right">
|
6
|
+
<a href="http://twitter.com/share" class="twitter-share-button">Tweet</a></p>
|
7
|
+
</div>
|
8
|
+
</p>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
|
3
|
+
var _gaq = _gaq || [];
|
4
|
+
_gaq.push(['_setAccount', 'UA-23306458-1']);
|
5
|
+
_gaq.push(['_trackPageview']);
|
6
|
+
|
7
|
+
(function () {
|
8
|
+
var ga = document.createElement('script');
|
9
|
+
ga.type = 'text/javascript';
|
10
|
+
ga.async = true;
|
11
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
12
|
+
var s = document.getElementsByTagName('script')[0];
|
13
|
+
s.parentNode.insertBefore(ga, s);
|
14
|
+
})();
|
15
|
+
|
16
|
+
</script>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<head>
|
2
|
+
<title>Active Admin | The administration framework for Ruby on Rails</title>
|
3
|
+
<link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:extralight,light,regular,bold' rel='stylesheet' type='text/css'>
|
4
|
+
<link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
5
|
+
<link href="{{ site.baseurl }}/stylesheets/main.css" media="screen" rel="stylesheet" type="text/css" />
|
6
|
+
<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
|
7
|
+
</head>
|
@@ -0,0 +1,97 @@
|
|
1
|
+
<ol class='level-1'>
|
2
|
+
<li><a href='{{ site.baseurl }}/0-installation.html'>Installation</a></li>
|
3
|
+
<ol class='level-2'>
|
4
|
+
<li><a href='{{ site.baseurl }}/0-installation.html#setting-up-active-admin'>Setting up Active Admin</a></li>
|
5
|
+
<li><a href='{{ site.baseurl }}/0-installation.html#upgrading'>Upgrading</a></li>
|
6
|
+
<li><a href='{{ site.baseurl }}/0-installation.html#gem-compatibility'>Gem Compatibility</a></li>
|
7
|
+
</ol>
|
8
|
+
<li><a href='{{ site.baseurl }}/1-general-configuration.html'>General Configuration</a></li>
|
9
|
+
<ol class='level-2'>
|
10
|
+
<li><a href='{{ site.baseurl }}/1-general-configuration.html#authentication'>Authentication</a></li>
|
11
|
+
<li><a href='{{ site.baseurl }}/1-general-configuration.html#site-title-options'>Site Title Options</a></li>
|
12
|
+
<li><a href='{{ site.baseurl }}/1-general-configuration.html#internationalization-(i18n)'>Internationalization (I18n)</a></li>
|
13
|
+
<li><a href='{{ site.baseurl }}/1-general-configuration.html#namespaces'>Namespaces</a></li>
|
14
|
+
<li><a href='{{ site.baseurl }}/1-general-configuration.html#load-paths'>Load paths</a></li>
|
15
|
+
<li><a href='{{ site.baseurl }}/1-general-configuration.html#comments'>Comments</a></li>
|
16
|
+
<li><a href='{{ site.baseurl }}/1-general-configuration.html#utility-navigation'>Utility Navigation</a></li>
|
17
|
+
</ol>
|
18
|
+
<li><a href='{{ site.baseurl }}/2-resource-customization.html'>Working with Resources</a></li>
|
19
|
+
<ol class='level-2'>
|
20
|
+
<li><a href='{{ site.baseurl }}/2-resource-customization.html#rename-the-resource'>Rename the Resource</a></li>
|
21
|
+
<li><a href='{{ site.baseurl }}/2-resource-customization.html#customize-the-namespace'>Customize the Namespace</a></li>
|
22
|
+
<li><a href='{{ site.baseurl }}/2-resource-customization.html#customize-the-menu'>Customize the Menu</a></li>
|
23
|
+
<li><a href='{{ site.baseurl }}/2-resource-customization.html#scoping-the-queries'>Scoping the queries</a></li>
|
24
|
+
<li><a href='{{ site.baseurl }}/2-resource-customization.html#customizing-resource-retrieval'>Customizing resource
|
25
|
+
retrieval</a></li>
|
26
|
+
<li><a href='{{ site.baseurl }}/2-resource-customization.html#belongs-to'>Belongs To</a></li>
|
27
|
+
</ol>
|
28
|
+
<li><a href='{{ site.baseurl }}/3-index-pages.html'>Customizing the Index Page</a></li>
|
29
|
+
<ol class='level-2'>
|
30
|
+
<li><a href='{{ site.baseurl }}/3-index-pages/create-an-index.html'>Create an Index</a></li>
|
31
|
+
<li><a href='{{ site.baseurl }}/3-index-pages/index-as-block.html'>Index as a Block</a></li>
|
32
|
+
<li><a href='{{ site.baseurl }}/3-index-pages/index-as-blog.html'>Index as Blog</a></li>
|
33
|
+
<li><a href='{{ site.baseurl }}/3-index-pages/index-as-grid.html'>Index as a Grid</a></li>
|
34
|
+
<li><a href='{{ site.baseurl }}/3-index-pages/index-as-table.html'>Index as a Table</a></li>
|
35
|
+
</ol>
|
36
|
+
<li><a href='{{ site.baseurl }}/4-csv-format.html'>Customizing the CSV format</a></li>
|
37
|
+
<li><a href='{{ site.baseurl }}/5-forms.html'>Customizing the Form</a></li>
|
38
|
+
<ol class='level-2'>
|
39
|
+
<li><a href='{{ site.baseurl }}/5-forms.html#default'>Default</a></li>
|
40
|
+
<li><a href='{{ site.baseurl }}/5-forms.html#partials'>Partials</a></li>
|
41
|
+
<li><a href='{{ site.baseurl }}/5-forms.html#nested-resources'>Nested Resources</a></li>
|
42
|
+
<li><a href='{{ site.baseurl }}/5-forms.html#datepicker'>Datepicker</a></li>
|
43
|
+
<li><a href='{{ site.baseurl }}/5-forms.html#displaying-errors'>Displaying Errors</a></li>
|
44
|
+
</ol>
|
45
|
+
<li><a href='{{ site.baseurl }}/6-show-pages.html'>Customize the Show Page</a></li>
|
46
|
+
<li><a href='{{ site.baseurl }}/7-sidebars.html'>Sidebar Sections</a></li>
|
47
|
+
<li><a href='{{ site.baseurl }}/8-custom-actions.html'>Custom Controller Actions</a></li>
|
48
|
+
<ol class='level-2'>
|
49
|
+
<li><a href='{{ site.baseurl }}/8-custom-actions.html#collection-actions'>Collection Actions</a></li>
|
50
|
+
<li><a href='{{ site.baseurl }}/8-custom-actions.html#member-actions'>Member Actions</a></li>
|
51
|
+
<li><a href='{{ site.baseurl }}/8-custom-actions.html#http-verbs'>HTTP Verbs</a></li>
|
52
|
+
<li><a href='{{ site.baseurl }}/8-custom-actions.html#rendering'>Rendering</a></li>
|
53
|
+
<li><a href='{{ site.baseurl }}/8-custom-actions.html#action-items'>Action Items</a></li>
|
54
|
+
<li><a href='{{ site.baseurl }}/8-custom-actions.html#modifying-the-controller'>Modifying the Controller</a></li>
|
55
|
+
</ol>
|
56
|
+
<li><a href='{{ site.baseurl }}/9-batch-actions.html'>Index Batch Actions</a></li>
|
57
|
+
<ol class='level-2'>
|
58
|
+
<li><a href='{{ site.baseurl }}/9-batch-actions.html#provided-batch-action'>Provided Batch Action</a></li>
|
59
|
+
<li><a href='{{ site.baseurl }}/9-batch-actions.html#creating-your-own'>Creating Your Own</a></li>
|
60
|
+
</ol>
|
61
|
+
<li><a href='{{ site.baseurl }}/10-custom-pages.html'>Custom Pages</a></li>
|
62
|
+
<ol class='level-2'>
|
63
|
+
<li><a href='{{ site.baseurl }}/10-custom-pages.html#create-a-new-page'>Create a new Page</a></li>
|
64
|
+
<li><a href='{{ site.baseurl }}/10-custom-pages.html#customize-the-menu'>Customize the Menu</a></li>
|
65
|
+
<li><a href='{{ site.baseurl }}/10-custom-pages.html#add-a-sidebar'>Add a Sidebar</a></li>
|
66
|
+
<li><a href='{{ site.baseurl }}/10-custom-pages.html#add-an-action-item'>Add an Action Item</a></li>
|
67
|
+
<li><a href='{{ site.baseurl }}/10-custom-pages.html#add-a-page-action'>Add a Page Action</a></li>
|
68
|
+
</ol>
|
69
|
+
<li><a href='{{ site.baseurl }}/11-decorators.html'>Decorators</a></li>
|
70
|
+
<ol class='level-2'>
|
71
|
+
<li><a href='{{ site.baseurl }}/11-decorators.html#example-usage'>Example Usage</a></li>
|
72
|
+
<li><a href='{{ site.baseurl }}/11-decorators.html#forms'>Forms</a></li>
|
73
|
+
</ol>
|
74
|
+
<li><a href='{{ site.baseurl }}/12-arbre-components.html'>Arbre Components</a></li>
|
75
|
+
<ol class='level-2'>
|
76
|
+
<li><a href='{{ site.baseurl }}/12-arbre-components.html#text-node'>Text Node</a></li>
|
77
|
+
<li><a href='{{ site.baseurl }}/12-arbre-components.html#panels'>Panels</a></li>
|
78
|
+
<li><a href='{{ site.baseurl }}/12-arbre-components.html#columns'>Columns</a></li>
|
79
|
+
<li><a href='{{ site.baseurl }}/12-arbre-components.html#table-for'>Table For</a></li>
|
80
|
+
<li><a href='{{ site.baseurl }}/12-arbre-components.html#status-tag'>Status tag</a></li>
|
81
|
+
</ol>
|
82
|
+
<li><a href='{{ site.baseurl }}/13-authorization-adapter.html'>Authorization Adapter</a></li>
|
83
|
+
<ol class='level-2'>
|
84
|
+
<li><a href='{{ site.baseurl }}/13-authorization-adapter.html#setting-up-your-own-authorizationadapter'>Setting up your own
|
85
|
+
AuthorizationAdapter</a></li>
|
86
|
+
<li><a href='{{ site.baseurl }}/13-authorization-adapter.html#getting-access-to-the-current-user'>Getting Access to the
|
87
|
+
Current User</a></li>
|
88
|
+
<li><a href='{{ site.baseurl }}/13-authorization-adapter.html#scoping-collections-in-authorization-adapters'>Scoping
|
89
|
+
Collections in Authorization Adapters</a></li>
|
90
|
+
<li><a href='{{ site.baseurl }}/13-authorization-adapter.html#managing-access-to-pages'>Managing Access to Pages</a></li>
|
91
|
+
<li><a href='{{ site.baseurl }}/13-authorization-adapter.html#action-types'>Action Types</a></li>
|
92
|
+
<li><a href='{{ site.baseurl }}/13-authorization-adapter.html#checking-for-authorization-in-controllers-and-views'>Checking
|
93
|
+
for Authorization in Controllers and Views</a></li>
|
94
|
+
<li><a href='{{ site.baseurl }}/13-authorization-adapter.html#using-the-cancan-adapter'>Using the CanCan Adapter</a></li>
|
95
|
+
<li><a href='{{ site.baseurl }}/13-authorization-adapter.html#using-the-pundit-adapter'>Using the Pundit Adapter</a></li>
|
96
|
+
</ol>
|
97
|
+
</ol>
|