activeadmin 1.0.0 → 1.1.0

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.
Files changed (276) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +20 -0
  3. data/.mdlrc +1 -0
  4. data/.rubocop.yml +52 -3
  5. data/.simplecov +13 -0
  6. data/.travis.yml +9 -24
  7. data/.yardopts +0 -1
  8. data/CHANGELOG.md +85 -4
  9. data/CONTRIBUTING.md +33 -57
  10. data/Gemfile +26 -17
  11. data/Rakefile +1 -12
  12. data/activeadmin.gemspec +9 -11
  13. data/app/assets/javascripts/active_admin/base.js.coffee +6 -2
  14. data/app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee +5 -1
  15. data/app/assets/javascripts/active_admin/initializers/datepicker.js.coffee +5 -1
  16. data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +5 -1
  17. data/app/assets/javascripts/active_admin/initializers/tabs.js.coffee +5 -1
  18. data/app/assets/javascripts/active_admin/lib/batch_actions.js.coffee +6 -3
  19. data/app/assets/javascripts/active_admin/lib/checkbox-toggler.js.coffee +9 -7
  20. data/app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee +5 -2
  21. data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +6 -2
  22. data/app/assets/javascripts/active_admin/lib/table-checkbox-toggler.js.coffee +3 -5
  23. data/app/assets/stylesheets/active_admin/_base.scss +2 -2
  24. data/app/assets/stylesheets/active_admin/_forms.scss +6 -12
  25. data/app/assets/stylesheets/active_admin/components/_batch_actions.scss +0 -5
  26. data/app/assets/stylesheets/active_admin/components/_pagination.scss +11 -0
  27. data/app/assets/stylesheets/active_admin/components/_status_tags.scss +1 -0
  28. data/app/assets/stylesheets/active_admin/components/_tables.scss +4 -1
  29. data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -2
  30. data/app/assets/stylesheets/active_admin/print.scss +2 -3
  31. data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
  32. data/app/views/active_admin/devise/shared/_links.erb +12 -6
  33. data/app/views/kaminari/active_admin/_first_page.html.erb +11 -0
  34. data/app/views/kaminari/active_admin/_gap.html.erb +8 -0
  35. data/app/views/kaminari/active_admin/_last_page.html.erb +11 -0
  36. data/app/views/kaminari/active_admin/_next_page.html.erb +11 -0
  37. data/app/views/kaminari/active_admin/_page.html.erb +12 -0
  38. data/app/views/kaminari/active_admin/_paginator.html.erb +25 -0
  39. data/app/views/kaminari/active_admin/_prev_page.html.erb +11 -0
  40. data/codecov.yml +14 -12
  41. data/config/i18n-tasks.yml +26 -0
  42. data/config/locales/ar.yml +1 -3
  43. data/config/locales/bg.yml +0 -2
  44. data/config/locales/bs.yml +0 -2
  45. data/config/locales/ca.yml +0 -2
  46. data/config/locales/cs.yml +0 -2
  47. data/config/locales/da.yml +1 -3
  48. data/config/locales/de-CH.yml +1 -3
  49. data/config/locales/de.yml +1 -3
  50. data/config/locales/el.yml +1 -3
  51. data/config/locales/en-CA.yml +138 -0
  52. data/config/locales/en-GB.yml +43 -3
  53. data/config/locales/en.yml +8 -4
  54. data/config/locales/es-MX.yml +3 -2
  55. data/config/locales/es.yml +10 -4
  56. data/config/locales/fa.yml +0 -2
  57. data/config/locales/fi.yml +0 -2
  58. data/config/locales/fr.yml +9 -2
  59. data/config/locales/he.yml +53 -7
  60. data/config/locales/hr.yml +0 -2
  61. data/config/locales/hu.yml +0 -2
  62. data/config/locales/id.yml +1 -3
  63. data/config/locales/it.yml +2 -4
  64. data/config/locales/ja.yml +1 -3
  65. data/config/locales/ko.yml +0 -2
  66. data/config/locales/lt.yml +24 -4
  67. data/config/locales/lv.yml +0 -2
  68. data/config/locales/nb.yml +0 -2
  69. data/config/locales/nl.yml +1 -3
  70. data/config/locales/pl.yml +3 -2
  71. data/config/locales/pt-BR.yml +1 -3
  72. data/config/locales/pt-PT.yml +0 -2
  73. data/config/locales/ro.yml +0 -2
  74. data/config/locales/ru.yml +1 -3
  75. data/config/locales/sk.yml +0 -2
  76. data/config/locales/sv-SE.yml +1 -3
  77. data/config/locales/tr.yml +0 -2
  78. data/config/locales/uk.yml +1 -3
  79. data/config/locales/vi.yml +0 -2
  80. data/config/locales/zh-CN.yml +0 -2
  81. data/config/locales/zh-TW.yml +1 -3
  82. data/config/mdl_style.rb +9 -0
  83. data/cucumber.yml +3 -3
  84. data/docs/0-installation.md +15 -12
  85. data/docs/1-general-configuration.md +10 -3
  86. data/docs/10-custom-pages.md +10 -5
  87. data/docs/11-decorators.md +1 -0
  88. data/docs/12-arbre-components.md +7 -9
  89. data/docs/13-authorization-adapter.md +39 -24
  90. data/docs/14-gotchas.md +41 -22
  91. data/docs/2-resource-customization.md +41 -18
  92. data/docs/3-index-pages.md +30 -12
  93. data/docs/3-index-pages/custom-index.md +1 -0
  94. data/docs/3-index-pages/index-as-block.md +0 -5
  95. data/docs/3-index-pages/index-as-blog.md +0 -5
  96. data/docs/3-index-pages/index-as-grid.md +0 -5
  97. data/docs/3-index-pages/index-as-table.md +1 -9
  98. data/docs/4-csv-format.md +2 -1
  99. data/docs/5-forms.md +45 -21
  100. data/docs/6-show-pages.md +2 -1
  101. data/docs/7-sidebars.md +2 -1
  102. data/docs/8-custom-actions.md +4 -1
  103. data/docs/9-batch-actions.md +4 -2
  104. data/docs/documentation.md +19 -21
  105. data/features/comments/commenting.feature +20 -0
  106. data/features/index/filters.feature +41 -1
  107. data/features/index/format_as_csv.feature +17 -0
  108. data/features/index/index_scopes.feature +15 -0
  109. data/features/registering_assets.feature +8 -4
  110. data/features/show/attributes_table_title.feature +54 -0
  111. data/features/show/tabs.feature +10 -4
  112. data/features/step_definitions/action_link_steps.rb +0 -1
  113. data/features/step_definitions/attributes_table_title_steps.rb +11 -0
  114. data/features/step_definitions/batch_action_steps.rb +2 -2
  115. data/features/step_definitions/comment_steps.rb +21 -1
  116. data/features/step_definitions/configuration_steps.rb +1 -1
  117. data/features/step_definitions/filter_steps.rb +9 -0
  118. data/features/step_definitions/format_steps.rb +1 -1
  119. data/features/step_definitions/index_scope_steps.rb +4 -0
  120. data/features/support/env.rb +5 -4
  121. data/features/support/regular_env.rb +7 -0
  122. data/features/support/reload_env.rb +7 -0
  123. data/gemfiles/rails_42.gemfile +2 -37
  124. data/gemfiles/rails_50.gemfile +5 -40
  125. data/gemfiles/rails_51.gemfile +5 -40
  126. data/lib/active_admin.rb +0 -3
  127. data/lib/active_admin/application.rb +6 -4
  128. data/lib/active_admin/asset_registration.rb +8 -0
  129. data/lib/active_admin/authorization_adapter.rb +0 -3
  130. data/lib/active_admin/base_controller.rb +1 -2
  131. data/lib/active_admin/base_controller/authorization.rb +0 -1
  132. data/lib/active_admin/base_controller/menu.rb +9 -9
  133. data/lib/active_admin/batch_actions/controller.rb +1 -1
  134. data/lib/active_admin/batch_actions/views/selection_cells.rb +6 -5
  135. data/lib/active_admin/csv_builder.rb +3 -3
  136. data/lib/active_admin/dependency.rb +1 -1
  137. data/lib/active_admin/devise.rb +2 -2
  138. data/lib/active_admin/dsl.rb +2 -2
  139. data/lib/active_admin/filters.rb +2 -0
  140. data/lib/active_admin/filters/active.rb +13 -14
  141. data/lib/active_admin/filters/active_filter.rb +87 -0
  142. data/lib/active_admin/filters/active_sidebar.rb +50 -0
  143. data/lib/active_admin/filters/forms.rb +1 -2
  144. data/lib/active_admin/filters/resource_extension.rb +2 -30
  145. data/lib/active_admin/helpers/settings.rb +0 -1
  146. data/lib/active_admin/inputs/datepicker_input.rb +5 -5
  147. data/lib/active_admin/inputs/filters/date_range_input.rb +12 -4
  148. data/lib/active_admin/inputs/filters/text_input.rb +0 -1
  149. data/lib/active_admin/menu.rb +4 -4
  150. data/lib/active_admin/menu_collection.rb +0 -2
  151. data/lib/active_admin/namespace.rb +1 -1
  152. data/lib/active_admin/orm/active_record/comments/comment.rb +1 -5
  153. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +4 -2
  154. data/lib/active_admin/page_controller.rb +1 -1
  155. data/lib/active_admin/resource/action_items.rb +4 -0
  156. data/lib/active_admin/resource/attributes.rb +1 -1
  157. data/lib/active_admin/resource/page_presenters.rb +1 -1
  158. data/lib/active_admin/resource/routes.rb +0 -1
  159. data/lib/active_admin/resource/scopes.rb +2 -1
  160. data/lib/active_admin/resource_controller.rb +1 -1
  161. data/lib/active_admin/resource_controller/data_access.rb +8 -9
  162. data/lib/active_admin/resource_dsl.rb +10 -10
  163. data/lib/active_admin/router.rb +1 -1
  164. data/lib/active_admin/scope.rb +3 -3
  165. data/lib/active_admin/version.rb +1 -1
  166. data/lib/active_admin/view_helpers.rb +1 -0
  167. data/lib/active_admin/view_helpers/display_helper.rb +1 -1
  168. data/lib/active_admin/view_helpers/form_helper.rb +1 -1
  169. data/lib/active_admin/view_helpers/scope_name_helper.rb +16 -0
  170. data/lib/active_admin/views/action_items.rb +1 -1
  171. data/lib/active_admin/views/components/active_admin_form.rb +1 -1
  172. data/lib/active_admin/views/components/dropdown_menu.rb +2 -2
  173. data/lib/active_admin/views/components/index_list.rb +0 -2
  174. data/lib/active_admin/views/components/paginated_collection.rb +1 -1
  175. data/lib/active_admin/views/components/scopes.rb +2 -10
  176. data/lib/active_admin/views/components/status_tag.rb +19 -11
  177. data/lib/active_admin/views/components/tabs.rb +2 -2
  178. data/lib/active_admin/views/header.rb +0 -1
  179. data/lib/active_admin/views/index_as_blog.rb +1 -2
  180. data/lib/active_admin/views/index_as_grid.rb +2 -2
  181. data/lib/active_admin/views/index_as_table.rb +19 -1
  182. data/lib/active_admin/views/pages/base.rb +4 -4
  183. data/lib/active_admin/views/pages/show.rb +6 -1
  184. data/lib/active_admin/views/title_bar.rb +4 -4
  185. data/lib/bug_report_templates/{rails_5_master.rb → active_admin_master.rb} +35 -40
  186. data/lib/generators/active_admin/devise/devise_generator.rb +1 -1
  187. data/lib/generators/active_admin/install/templates/admin_user.rb.erb +1 -1
  188. data/spec/bug_report_templates_spec.rb +2 -3
  189. data/spec/rails_helper.rb +0 -3
  190. data/spec/spec_helper.rb +1 -12
  191. data/spec/support/active_admin_integration_spec_helper.rb +1 -1
  192. data/spec/support/rails_template.rb +5 -37
  193. data/spec/support/rails_template_with_data.rb +262 -3
  194. data/spec/support/templates/policies/active_admin/comment_policy.rb +1 -1
  195. data/spec/support/templates/policies/active_admin/page_policy.rb +1 -1
  196. data/spec/support/templates/policies/application_policy.rb +1 -2
  197. data/spec/support/templates/post_decorator.rb +0 -1
  198. data/spec/unit/abstract_view_factory_spec.rb +0 -1
  199. data/spec/unit/application_spec.rb +4 -0
  200. data/spec/unit/asset_registration_spec.rb +29 -0
  201. data/spec/unit/belongs_to_spec.rb +1 -2
  202. data/spec/unit/config_shared_examples.rb +1 -1
  203. data/spec/unit/csv_builder_spec.rb +2 -4
  204. data/spec/unit/dependency_spec.rb +7 -7
  205. data/spec/unit/dsl_spec.rb +0 -2
  206. data/spec/unit/filters/active_filter_spec.rb +135 -0
  207. data/spec/unit/filters/active_spec.rb +11 -1
  208. data/spec/unit/filters/filter_form_builder_spec.rb +9 -7
  209. data/spec/unit/form_builder_spec.rb +14 -14
  210. data/spec/unit/helpers/scope_chain_spec.rb +0 -1
  211. data/spec/unit/i18n_spec.rb +17 -0
  212. data/spec/unit/menu_item_spec.rb +1 -3
  213. data/spec/unit/namespace/register_page_spec.rb +1 -1
  214. data/spec/unit/namespace_spec.rb +0 -1
  215. data/spec/unit/page_spec.rb +0 -3
  216. data/spec/unit/resource/action_items_spec.rb +5 -1
  217. data/spec/unit/resource/attributes_spec.rb +1 -2
  218. data/spec/unit/resource/ordering_spec.rb +0 -3
  219. data/spec/unit/resource/scopes_spec.rb +1 -1
  220. data/spec/unit/resource_controller/data_access_spec.rb +2 -2
  221. data/spec/unit/resource_controller_spec.rb +1 -2
  222. data/spec/unit/resource_spec.rb +9 -2
  223. data/spec/unit/routing_spec.rb +0 -2
  224. data/spec/unit/scope_spec.rb +3 -3
  225. data/spec/unit/settings_spec.rb +0 -1
  226. data/spec/unit/view_factory_spec.rb +1 -1
  227. data/spec/unit/view_helpers/flash_helper_spec.rb +0 -1
  228. data/spec/unit/view_helpers/form_helper_spec.rb +3 -4
  229. data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +0 -1
  230. data/spec/unit/views/components/attributes_table_spec.rb +0 -1
  231. data/spec/unit/views/components/columns_spec.rb +0 -2
  232. data/spec/unit/views/components/site_title_spec.rb +0 -2
  233. data/spec/unit/views/components/status_tag_spec.rb +23 -7
  234. data/spec/unit/views/components/tabs_spec.rb +29 -1
  235. data/spec/unit/views/pages/index_spec.rb +1 -1
  236. data/tasks/docs.rake +37 -10
  237. data/tasks/lint.rake +14 -1
  238. data/tasks/local.rake +2 -2
  239. data/tasks/test.rake +8 -25
  240. data/vendor/assets/javascripts/jquery-ui/data.js +41 -0
  241. data/vendor/assets/javascripts/jquery-ui/disable-selection.js +48 -0
  242. data/vendor/assets/javascripts/jquery-ui/escape-selector.js +23 -0
  243. data/vendor/assets/javascripts/jquery-ui/focusable.js +86 -0
  244. data/vendor/assets/javascripts/jquery-ui/ie.js +17 -0
  245. data/vendor/assets/javascripts/jquery-ui/keycode.js +47 -0
  246. data/vendor/assets/javascripts/jquery-ui/plugin.js +46 -0
  247. data/vendor/assets/javascripts/jquery-ui/position.js +500 -0
  248. data/vendor/assets/javascripts/jquery-ui/safe-active-element.js +42 -0
  249. data/vendor/assets/javascripts/jquery-ui/safe-blur.js +23 -0
  250. data/vendor/assets/javascripts/jquery-ui/scroll-parent.js +47 -0
  251. data/vendor/assets/javascripts/jquery-ui/tabbable.js +38 -0
  252. data/vendor/assets/javascripts/jquery-ui/unique-id.js +51 -0
  253. data/vendor/assets/javascripts/jquery-ui/version.js +17 -0
  254. data/vendor/assets/javascripts/jquery-ui/widget.js +735 -0
  255. data/vendor/assets/javascripts/jquery-ui/widgets/button.js +391 -0
  256. data/vendor/assets/javascripts/jquery-ui/widgets/checkboxradio.js +300 -0
  257. data/vendor/assets/javascripts/jquery-ui/widgets/controlgroup.js +300 -0
  258. data/vendor/assets/javascripts/jquery-ui/widgets/datepicker.js +2123 -0
  259. data/vendor/assets/javascripts/jquery-ui/widgets/dialog.js +954 -0
  260. data/vendor/assets/javascripts/jquery-ui/widgets/draggable.js +1259 -0
  261. data/vendor/assets/javascripts/jquery-ui/widgets/mouse.js +230 -0
  262. data/vendor/assets/javascripts/jquery-ui/widgets/resizable.js +1207 -0
  263. data/vendor/assets/javascripts/jquery-ui/widgets/sortable.js +1561 -0
  264. data/vendor/assets/javascripts/jquery-ui/widgets/tabs.js +931 -0
  265. data/vendor/assets/stylesheets/active_admin/_normalize.scss +447 -0
  266. metadata +62 -51
  267. data/.hound.yml +0 -14
  268. data/Appraisals +0 -41
  269. data/app/assets/images/active_admin/datepicker/datepicker-input-icon.png +0 -0
  270. data/app/assets/javascripts/active_admin/jquery_ui.js.erb +0 -18
  271. data/app/assets/stylesheets/active_admin/mixins/_reset.scss +0 -165
  272. data/lib/active_admin/filters/humanized.rb +0 -68
  273. data/spec/requests/javascript_spec.rb +0 -22
  274. data/spec/support/jslint.yml +0 -80
  275. data/spec/unit/filters/humanized_spec.rb +0 -64
  276. data/tasks/yard.rake +0 -9
@@ -68,7 +68,6 @@
68
68
  one: "成功刪除 1 %{model}"
69
69
  other: "成功刪除 %{count} %{plural_model}"
70
70
  selection_toggle_explanation: "(切換選取)"
71
- link: "建立一個"
72
71
  action_label: "%{title} 已選取"
73
72
  labels:
74
73
  destroy: "刪除"
@@ -78,7 +77,6 @@
78
77
  author_type: "作者身份"
79
78
  body: "內文"
80
79
  author: "作者"
81
- title: "評論"
82
80
  add: "新增評論"
83
81
  delete: "刪除評論"
84
82
  delete_confirmation: "你確定要刪除這些評論嗎?"
@@ -126,7 +124,7 @@
126
124
  unsupported_browser:
127
125
  headline: "很抱歉,ActiveAdmin 已不再支援 Internet Explorer 8 以下版本的瀏覽器。"
128
126
  recommendation: "建議您升級到最新版本的<a href=\"http://windows.microsoft.com/ie\">Internet Explorer</a>,<a href=\"https://chrome.google.com/\">Google Chrome</a>,或是 <a href=\"https://mozilla.org/firefox/\">Firefox</a>。"
129
- turn_off_compatibility_view: "若您是使用 IE 9 或更新的版本,請確認<a href=\"http://windows.microsoft.com/zh-TW/windows7/webpages-look-incorrect-in-Internet-Explorer\">「相容性檢視」是關閉的</a>。"
127
+ turn_off_compatibility_view: "若您是使用 IE 9 或更新的版本,請確認<a href=\"https://support.microsoft.com/zh-tw/help/17471\">「相容性檢視」是關閉的</a>。"
130
128
  access_denied:
131
129
  message: "您沒有權限執行此項操作"
132
130
  index_list:
@@ -0,0 +1,9 @@
1
+ all
2
+
3
+ exclude_rule "first-header-h1"
4
+
5
+ exclude_rule "line-length"
6
+
7
+ rule "no-trailing-punctuation", punctuation: ".,;:!"
8
+
9
+ exclude_rule "first-line-h1"
@@ -1,3 +1,3 @@
1
- default: --format 'progress' --require features/support/env.rb --require features/step_definitions features --tags ~@requires-reloading --tags ~@wip
2
- wip: --format 'progress' --require features/support/env.rb --require features/step_definitions features --tags @wip:3 --wip features
3
- class-reloading: CLASS_RELOADING=true --format 'progress' --require features/support/env.rb --require features/step_definitions features --tags @requires-reloading
1
+ default: --format 'progress' --require features/support/regular_env.rb features --tags ~@requires-reloading --tags ~@wip
2
+ wip: --format 'progress' --require features/support/env.rb features --tags @wip:3 --wip features
3
+ class-reloading: CLASS_RELOADING=true --format 'progress' --require features/support/reload_env.rb features --tags @requires-reloading
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  redirect_from: /docs/0-installation.html
3
3
  ---
4
+
4
5
  # Installation
5
6
 
6
7
  Active Admin is a Ruby Gem.
@@ -22,29 +23,30 @@ that can be injected into your existing Ruby on Rails application.
22
23
 
23
24
  After installing the gem, you need to run the generator. Here are your options:
24
25
 
25
- - If you don't want to use Devise, run it with `--skip-users`:
26
+ * If you don't want to use Devise, run it with `--skip-users`:
27
+
26
28
  ```sh
27
29
  rails g active_admin:install --skip-users
28
30
  ```
29
31
 
30
- - If you want to use an existing user class, provide it as an argument:
32
+ * If you want to use an existing user class, provide it as an argument:
33
+
31
34
  ```sh
32
35
  rails g active_admin:install User
33
36
  ```
34
37
 
35
- - Otherwise, with no arguments we will create an `AdminUser` class to use with Devise:
38
+ * Otherwise, with no arguments we will create an `AdminUser` class to use with Devise:
39
+
36
40
  ```sh
37
41
  rails g active_admin:install
38
42
  ```
39
43
 
40
44
  The generator adds these core files, among others:
41
45
 
42
- ```
43
- app/admin/dashboard.rb
44
- app/assets/javascripts/active_admin.js.coffee
45
- app/assets/stylesheets/active_admin.scss
46
- config/initializers/active_admin.rb
47
- ```
46
+ * `app/admin/dashboard.rb`
47
+ * `app/assets/javascripts/active_admin.js.coffee`
48
+ * `app/assets/stylesheets/active_admin.scss`
49
+ * `config/initializers/active_admin.rb`
48
50
 
49
51
  Now, migrate and seed your database before starting the server:
50
52
 
@@ -67,7 +69,8 @@ To register an existing model with Active Admin:
67
69
  rails generate active_admin:resource MyModel
68
70
  ```
69
71
 
70
- This creates a file at `app/admin/my_model.rb` to set up the UI; refresh your browser to see it.
72
+ This creates a file at `app/admin/my_model.rb` to set up the UI; refresh your
73
+ browser to see it.
71
74
 
72
75
  # Upgrading
73
76
 
@@ -98,8 +101,8 @@ Kaminari.configure do |config|
98
101
  end
99
102
  ```
100
103
 
101
- If you are also using [Draper](https://github.com/drapergem/draper), you may want to
102
- make sure `per_page_kaminari` is delegated correctly:
104
+ If you are also using [Draper](https://github.com/drapergem/draper), you may
105
+ want to make sure `per_page_kaminari` is delegated correctly:
103
106
 
104
107
  ```ruby
105
108
  Draper::CollectionDecorator.send :delegate, :per_page_kaminari
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  redirect_from: /docs/1-general-configuration.html
3
3
  ---
4
+
4
5
  # General Configuration
5
6
 
6
7
  You can configure Active Admin settings in `config/initializers/active_admin.rb`.
@@ -45,10 +46,12 @@ config.site_title_image = ->(context) { context.current_user.company.logo_url }
45
46
 
46
47
  ## Internationalization (I18n)
47
48
 
48
- To translate Active Admin to a new language or customize an existing translation, you can copy
49
+ To translate Active Admin to a new language or customize an existing
50
+ translation, you can copy
49
51
  [config/locales/en.yml](https://github.com/activeadmin/activeadmin/blob/master/config/locales/en.yml)
50
- to your application's `config/locales` folder and update it. We welcome new/updated translations,
51
- so feel free to [contribute](https://github.com/activeadmin/activeadmin/blob/master/CONTRIBUTING.md)!
52
+ to your application's `config/locales` folder and update it. We welcome
53
+ new/updated translations, so feel free to
54
+ [contribute](https://github.com/activeadmin/activeadmin/blob/master/CONTRIBUTING.md)!
52
55
  To translate third party gems like devise, use for example devise-i18n.
53
56
 
54
57
  ## Localize Format For Dates and Times
@@ -140,16 +143,19 @@ config.comments_registration_name = 'AdminComment'
140
143
 
141
144
  You can change the order for the comments and you can change the column to be
142
145
  used for ordering:
146
+
143
147
  ```ruby
144
148
  config.comments_order = 'created_at ASC'
145
149
  ```
146
150
 
147
151
  You can disable the menu item for the comments index page:
152
+
148
153
  ```ruby
149
154
  config.comments_menu = false
150
155
  ```
151
156
 
152
157
  You can customize the comment menu:
158
+
153
159
  ```ruby
154
160
  config.comments_menu = { parent: 'Admin', priority: 1 }
155
161
  ```
@@ -177,6 +183,7 @@ end
177
183
 
178
184
  By default, Active Admin displays a "Powered by ActiveAdmin" message on every
179
185
  page. You can override this message and show domain-specific messaging:
186
+
180
187
  ```ruby
181
188
  config.footer = "MyApp Revision v1.3"
182
189
  ```
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  redirect_from: /docs/10-custom-pages.html
3
3
  ---
4
+
4
5
  # Custom Pages
5
6
 
6
7
  If you have data you want on a standalone page that isn't tied to a resource,
@@ -52,7 +53,7 @@ end
52
53
 
53
54
  See the [Menu](2-resource-customization.md#customize-the-menu) documentation.
54
55
 
55
- ## Customize the breadcrumbs
56
+ ## Customize the breadcrumbs
56
57
 
57
58
  ```ruby
58
59
  ActiveAdmin.register_page "Calendar" do
@@ -85,7 +86,8 @@ ActiveAdmin.register_page "Status" do
85
86
  end
86
87
  ```
87
88
 
88
- See also the [Belongs To](2-resource-customization.md#belongs-to) documentation and examples.
89
+ See also the [Belongs To](2-resource-customization.md#belongs-to) documentation
90
+ and examples.
89
91
 
90
92
  ## Add a Sidebar
91
93
 
@@ -104,7 +106,8 @@ end
104
106
 
105
107
  ## Add a Page Action
106
108
 
107
- Page actions are custom controller actions (which mirror the resource DSL for the same feature).
109
+ Page actions are custom controller actions (which mirror the resource DSL for
110
+ the same feature).
108
111
 
109
112
  ```ruby
110
113
  page_action :add_event, method: :post do
@@ -119,7 +122,8 @@ end
119
122
 
120
123
  This defines the route `/admin/calendar/add_event` which can handle HTTP POST requests.
121
124
 
122
- Clicking on the action item will reload page and display the message "Your event was added"
125
+ Clicking on the action item will reload page and display the message "Your event
126
+ was added"
123
127
 
124
128
  Page actions can handle multiple HTTP verbs.
125
129
 
@@ -128,4 +132,5 @@ page_action :add_event, method: [:get, :post] do
128
132
  # ...
129
133
  end
130
134
  ```
131
- See also the [Custom Actions](8-custom-actions.md#http-verbs) example.
135
+
136
+ See also the [Custom Actions](8-custom-actions.md#http-verbs) example.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  redirect_from: /docs/11-decorators.html
3
3
  ---
4
+
4
5
  # Decorators
5
6
 
6
7
  Active Admin allows you to use the decorator pattern to provide view-specific
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  redirect_from: /docs/12-arbre-components.html
3
3
  ---
4
+
4
5
  # Arbre Components
5
6
 
6
7
  Arbre allows the creation of shareable and extendable HTML components and is
@@ -21,7 +22,7 @@ ActiveAdmin.register Post do
21
22
  row :id
22
23
  row 'Tags' do
23
24
  post.tags.each do |tag|
24
- a tag, href: admin_post_path(q: {tagged_with_contains: tag})
25
+ a tag, href: admin_post_path(q: {tagged_with_contains: tag})
25
26
  text_node "&nbsp;".html_safe
26
27
  end
27
28
  end
@@ -57,7 +58,7 @@ The Columns component allows you draw content into scalable columns. All you
57
58
  need to do is define the number of columns and the component will take care of
58
59
  the rest.
59
60
 
60
- #### Simple Columns
61
+ ### Simple Columns
61
62
 
62
63
  To create simple columns, use the `columns` method. Within the block, call
63
64
  the #column method to create a new column.
@@ -138,18 +139,15 @@ takes a block.
138
139
  Status tags provide convenient syntactic sugar for styling items that have
139
140
  status. A common example of where the status tag could be useful is for orders
140
141
  that are complete or in progress. `status_tag` takes a status, like
141
- "In Progress", a type, which defaults to nil, and a hash of options. The
142
- status_tag will generate html markup that Active Admin css uses in styling.
142
+ "In Progress", and a hash of options. The status_tag will generate HTML markup
143
+ that Active Admin CSS uses in styling.
143
144
 
144
145
  ```ruby
145
146
  status_tag 'In Progress'
146
147
  # => <span class='status_tag in_progress'>In Progress</span>
147
148
 
148
- status_tag 'active', :ok
149
- # => <span class='status_tag active ok'>Active</span>
150
-
151
- status_tag 'active', :ok, class: 'important', id: 'status_123', label: 'on'
152
- # => <span class='status_tag active ok important' id='status_123'>on</span>
149
+ status_tag 'active', class: 'important', id: 'status_123', label: 'on'
150
+ # => <span class='status_tag active important' id='status_123'>on</span>
153
151
  ```
154
152
 
155
153
  ## Tabs
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  redirect_from: /docs/13-authorization-adapter.html
3
3
  ---
4
+
4
5
  # Authorization Adapter
5
6
 
6
7
  Active Admin offers the ability to define and use your own authorization
@@ -40,7 +41,8 @@ application's `config/initializers/active_admin.rb` and add/modify the line:
40
41
  config.authorization_adapter = "OnlyAuthorsAuthorization"
41
42
  ```
42
43
 
43
- Authorization adapters can be configured per ActiveAdmin namespace as well, for example:
44
+ Authorization adapters can be configured per ActiveAdmin namespace as well, for
45
+ example:
44
46
 
45
47
  ```ruby
46
48
  ActiveAdmin.setup do |config|
@@ -73,9 +75,9 @@ end
73
75
 
74
76
  ## Scoping Collections in Authorization Adapters
75
77
 
76
- `ActiveAdmin::AuthorizationAdapter` also provides a hook method (`#scope_collection`)
77
- for the adapter to scope the resource's collection. For example, you may want to
78
- centralize the scoping:
78
+ `ActiveAdmin::AuthorizationAdapter` also provides a hook method
79
+ (`#scope_collection`) for the adapter to scope the resource's collection. For
80
+ example, you may want to centralize the scoping:
79
81
 
80
82
  ```ruby
81
83
  class OnlyMyAccount < ActiveAdmin::AuthorizationAdapter
@@ -104,7 +106,9 @@ class OnlyDashboard < ActiveAdmin::AuthorizationAdapter
104
106
  def authorized?(action, subject = nil)
105
107
  case subject
106
108
  when ActiveAdmin::Page
107
- action == :read && subject.name == "Dashboard" && subject.namespace.name == :admin
109
+ action == :read &&
110
+ subject.name == "Dashboard" &&
111
+ subject.namespace.name == :admin
108
112
  else
109
113
  false
110
114
  end
@@ -116,24 +120,23 @@ end
116
120
 
117
121
  By default Active Admin simplifies the controller actions into 4 actions:
118
122
 
119
- * `:read` - This controls if the user can view the menu item as well as the
120
- index and show screens.
121
- * `:create` - This controls if the user can view the new screen and submit
122
- the form to the create action.
123
- * `:update` - This controls if the user can view the edit screen and submit
124
- the form to the update action.
125
- * `:destroy` - This controls if the user can delete a resource.
123
+ * `:read` - This controls if the user can view the menu item as well as the
124
+ index and show screens.
125
+ * `:create` - This controls if the user can view the new screen and submit
126
+ the form to the create action.
127
+ * `:update` - This controls if the user can view the edit screen and submit
128
+ the form to the update action.
129
+ * `:destroy` - This controls if the user can delete a resource.
126
130
 
127
131
  Each of these actions is available as a constant. Eg: `:read` is available as
128
132
  `ActiveAdmin::Authorization::READ`.
129
133
 
130
-
131
134
  ## Checking for Authorization in Controllers and Views
132
135
 
133
136
  Active Admin provides a helper method to check if the current user is
134
137
  authorized to perform an action on a subject.
135
138
 
136
- Simply use the `#authorized?(action, subject) method to check.
139
+ Simply use the `#authorized?(action, subject)` method to check.
137
140
 
138
141
  ```ruby
139
142
  ActiveAdmin.register Post do
@@ -187,18 +190,19 @@ initializer:
187
190
  config.authorization_adapter = ActiveAdmin::CanCanAdapter
188
191
  ```
189
192
 
190
- You can also specify a method to be called on unauthorized access. This is necessary
191
- in order to prevent a redirect loop that can happen if a user tries to access a page
192
- they don't have permissions for (see [#2081](https://github.com/activeadmin/activeadmin/issues/2081)).
193
+ You can also specify a method to be called on unauthorized access. This is
194
+ necessary in order to prevent a redirect loop that can happen if a user tries to
195
+ access a page they don't have permissions for (see
196
+ [#2081](https://github.com/activeadmin/activeadmin/issues/2081)).
193
197
 
194
198
  ```ruby
195
199
  config.on_unauthorized_access = :access_denied
196
200
  ```
197
201
 
198
- The method `access_denied` would be defined in `application_controller.rb`. Here is one
199
- example that redirects the user from the page they don't have permission to
200
- access to a resource they have permission to access (organizations in this case), and
201
- also displays the error message in the browser:
202
+ The method `access_denied` would be defined in `application_controller.rb`. Here
203
+ is one example that redirects the user from the page they don't have permission
204
+ to access to a resource they have permission to access (organizations in this
205
+ case), and also displays the error message in the browser:
202
206
 
203
207
  ```ruby
204
208
  class ApplicationController < ActionController::Base
@@ -235,11 +239,14 @@ class Ability
235
239
  end
236
240
  ```
237
241
 
238
- To view more details about the API's, visit project pages of [CanCan](https://github.com/ryanb/cancan) and [CanCanCan](https://github.com/CanCanCommunity/cancancan).
242
+ To view more details about the API's, visit project pages of
243
+ [CanCan](https://github.com/ryanb/cancan) and
244
+ [CanCanCan](https://github.com/CanCanCommunity/cancancan).
239
245
 
240
246
  ## Using the Pundit Adapter
241
247
 
242
- Active Admin provides an adapter out of the box also for [Pundit](https://github.com/elabs/pundit).
248
+ Active Admin provides an adapter out of the box also for
249
+ [Pundit](https://github.com/elabs/pundit).
243
250
 
244
251
  To use the Pundit adapter, simply update the configuration in the Active Admin
245
252
  initializer:
@@ -248,4 +255,12 @@ initializer:
248
255
  config.authorization_adapter = ActiveAdmin::PunditAdapter
249
256
  ```
250
257
 
251
- You can simply use Pundit the way that you would expect and Active Admin will use it for authorization. Check Pundit's documentation to [set up Pundit in your application](https://github.com/elabs/pundit#installation). If you want to use batch actions just ensure that `destroy_all?` method is defined in your policy class. You can use this [template policy](https://github.com/activeadmin/activeadmin/blob/master/spec/support/templates/policies/application_policy.rb) in your application instead of default one generated by Pundit's `rails g pundit:install` command.
258
+ You can simply use Pundit the way that you would expect and Active Admin will
259
+ use it for authorization. Check Pundit's documentation to [set up Pundit in your
260
+ application](https://github.com/elabs/pundit#installation). If you want to use
261
+ batch actions just ensure that `destroy_all?` method is defined in your policy
262
+ class. You can use this [template
263
+ policy](https://github.com/activeadmin/activeadmin/blob/master/spec/support/templates/policies/application_policy.rb)
264
+ in your application instead of default one generated by Pundit's `rails g
265
+ pundit:install` command.
266
+
@@ -1,24 +1,29 @@
1
1
  ---
2
2
  redirect_from: /docs/14-gotchas.html
3
3
  ---
4
- #Gotchas
4
+
5
+ # Gotchas
5
6
 
6
7
  ## Security
7
8
 
8
9
  ### Spreadsheet applications vulnerable to unescaped CSV data
9
10
 
10
- If your CSV export includes untrusted data provided by your users, it's possible that they could include an executable formula that could call arbitrary commands on your computer. See [#4256](https://github.com/activeadmin/activeadmin/issues/4256) for more details.
11
+ If your CSV export includes untrusted data provided by your users, it's possible
12
+ that they could include an executable formula that could call arbitrary commands
13
+ on your computer. See
14
+ [#4256](https://github.com/activeadmin/activeadmin/issues/4256) for more
15
+ details.
11
16
 
12
17
  ## Session Commits & Asset Pipeline
13
18
 
14
- When configuring the asset pipeline ensure that the asset prefix
15
- (`config.assets.prefix`) is not the same as the namespace of ActiveAdmin
16
- (default namespace is `/admin`). If they are the same Sprockets will prevent the
17
- session from being committed. Flash messages won't work and you will be unable to
19
+ When configuring the asset pipeline ensure that the asset prefix
20
+ (`config.assets.prefix`) is not the same as the namespace of ActiveAdmin
21
+ (default namespace is `/admin`). If they are the same Sprockets will prevent the
22
+ session from being committed. Flash messages won't work and you will be unable to
18
23
  use the session for storing anything.
19
24
 
20
- For more information see the following post:
21
- [http://www.intridea.com/blog/2013/3/20/rails-assets-prefix-may-disable-your-session](http://www.intridea.com/blog/2013/3/20/rails-assets-prefix-may-disable-your-session)
25
+ For more information see [the following
26
+ post](http://www.intridea.com/blog/2013/3/20/rails-assets-prefix-may-disable-your-session).
22
27
 
23
28
  ## Helpers
24
29
 
@@ -27,13 +32,14 @@ find a solution.
27
32
 
28
33
  ### Helpers are not reloading in development
29
34
 
30
- This is a known and still open [issue](https://github.com/activeadmin/activeadmin/issues/697)
31
- the only way is to restart your server each time you change a helper.
35
+ This is a known and still open
36
+ [issue](https://github.com/activeadmin/activeadmin/issues/697) the only way is
37
+ to restart your server each time you change a helper.
32
38
 
33
39
  ### Helper maybe not included by default
34
40
 
35
- If you use `config.action_controller.include_all_helpers = false` in your application config,
36
- you need to include it by hand.
41
+ If you use `config.action_controller.include_all_helpers = false` in your
42
+ application config, you need to include it by hand.
37
43
 
38
44
  #### Solutions
39
45
 
@@ -62,23 +68,27 @@ end
62
68
 
63
69
  ## CSS
64
70
 
65
- In order to avoid the override of your application style with the Active Admin one, you can do one of these things:
66
- * You can properly move the generated file `active_admin.scss` from `app/assets/stylesheets` to `vendor/assets/stylesheets`.
67
- * You can remove all `require_tree` commands from your root level css files, where the `active_admin.scss` is in the tree.
71
+ In order to avoid the override of your application style with the Active Admin
72
+ one, you can do one of these things:
73
+
74
+ * You can properly move the generated file `active_admin.scss` from
75
+ `app/assets/stylesheets` to `vendor/assets/stylesheets`.
76
+ * You can remove all `require_tree` commands from your root level css files,
77
+ where the `active_admin.scss` is in the tree.
68
78
 
69
79
  ## Conflicts
70
80
 
71
81
  ### With gems that provides a `search` class method on a model
72
82
 
73
- If a gem defines a `search` class method on a model, this can result in conflicts
83
+ If a gem defines a `search` class method on a model, this can result in conflicts
74
84
  with the same method provided by `ransack` (a dependency of ActiveAdmin).
75
85
 
76
- Each of this conflicts need to solved is a different way. Some solutions are
86
+ Each of this conflicts need to solved is a different way. Some solutions are
77
87
  listed below.
78
88
 
79
89
  #### `tire`, `retire` and `elasticsearch-rails`
80
90
 
81
- This conflict can be solved, by using explicitly the `search` method of `tire`,
91
+ This conflict can be solved, by using explicitly the `search` method of `tire`,
82
92
  `retire` or `elasticsearch-rails`:
83
93
 
84
94
  ##### For `tire` and `retire`
@@ -101,9 +111,12 @@ YourModel.solr_search
101
111
 
102
112
  ### Rails 5 scaffold generators
103
113
 
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 [activeadmin/inherited_resources#195](https://github.com/activeadmin/inherited_resources/issues/195)
114
+ Active Admin requires the `inherited_resources` gem which may break scaffolding
115
+ under Rails 5 as it replaces the default scaffold generator. The solution is to
116
+ configure the default controller in `config/application.rb` as outlined in
117
+ [activeadmin/inherited_resources#195](https://github.com/activeadmin/inherited_resources/issues/195)
105
118
 
106
- ```
119
+ ```ruby
107
120
  module SampleApp
108
121
  class Application < Rails::Application
109
122
  ...
@@ -113,7 +126,13 @@ module SampleApp
113
126
  end
114
127
  ```
115
128
 
116
-
117
129
  ## Authentication & Application Controller
118
130
 
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`.
131
+ The `ActiveAdmin::BaseController` inherits from the `ApplicationController`. Any
132
+ authentication method(s) specified in the `ApplicationController` callbacks will
133
+ be called instead of the authentication method in the active admin config file.
134
+ For example, if the ApplicationController has a callback `before_action
135
+ :custom_authentication_method` and the config file's authentication method is
136
+ `config.authentication_method = :authenticate_active_admin_user`, then
137
+ `custom_authentication_method` will be called instead of
138
+ `authenticate_active_admin_user`.