activeadmin 1.0.0.pre1 → 1.0.0.pre2

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.

Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -16
  3. data/CHANGELOG.md +18 -1013
  4. data/Gemfile +18 -11
  5. data/LICENSE +0 -5
  6. data/README.md +0 -2
  7. data/activeadmin.gemspec +3 -1
  8. data/app/assets/javascripts/active_admin/application.js.coffee +8 -3
  9. data/app/assets/javascripts/active_admin/base.js.coffee +1 -6
  10. data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -0
  11. data/app/assets/javascripts/active_admin/lib/flash.js.coffee +1 -1
  12. data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +11 -3
  13. data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +5 -1
  14. data/app/assets/stylesheets/active_admin/_base.scss +1 -4
  15. data/app/assets/stylesheets/active_admin/_forms.scss +13 -8
  16. data/app/assets/stylesheets/active_admin/components/_buttons.scss +0 -5
  17. data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -1
  18. data/app/assets/stylesheets/active_admin/mixins/_sections.scss +0 -1
  19. data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
  20. data/app/assets/stylesheets/active_admin/mixins/_variables.scss +1 -1
  21. data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +0 -5
  22. data/app/views/layouts/active_admin_logged_out.html.erb +4 -0
  23. data/config/locales/ar.yml +14 -2
  24. data/config/locales/de-CH.yml +2 -0
  25. data/config/locales/de.yml +15 -0
  26. data/config/locales/en.yml +10 -2
  27. data/config/locales/es.yml +26 -4
  28. data/config/locales/fr.yml +5 -0
  29. data/config/locales/id.yml +135 -0
  30. data/config/locales/ja.yml +21 -3
  31. data/config/locales/ko.yml +66 -36
  32. data/config/locales/nl.yml +14 -1
  33. data/config/locales/pt-BR.yml +11 -0
  34. data/config/locales/ru.yml +15 -1
  35. data/config/locales/sv-SE.yml +45 -5
  36. data/config/locales/uk.yml +16 -4
  37. data/config/locales/zh-CN.yml +5 -0
  38. data/config/locales/zh-TW.yml +32 -1
  39. data/docs/0-installation.md +7 -1
  40. data/docs/1-general-configuration.md +9 -0
  41. data/docs/10-custom-pages.md +10 -0
  42. data/docs/12-arbre-components.md +1 -1
  43. data/docs/14-gotchas.md +2 -2
  44. data/docs/2-resource-customization.md +5 -3
  45. data/docs/3-index-pages.md +7 -0
  46. data/docs/3-index-pages/index-as-table.md +4 -0
  47. data/docs/6-show-pages.md +1 -1
  48. data/docs/7-sidebars.md +8 -0
  49. data/features/index/batch_actions.feature +21 -2
  50. data/features/index/pagination.feature +16 -12
  51. data/features/meta_tags.feature +21 -0
  52. data/features/registering_assets.feature +1 -2
  53. data/features/show/columns.feature +40 -0
  54. data/features/show/default_content.feature +2 -1
  55. data/features/step_definitions/asset_steps.rb +3 -3
  56. data/features/step_definitions/batch_action_steps.rb +11 -2
  57. data/features/step_definitions/column_steps.rb +8 -0
  58. data/features/step_definitions/configuration_steps.rb +2 -2
  59. data/features/step_definitions/factory_steps.rb +3 -2
  60. data/features/step_definitions/meta_tag_steps.rb +3 -0
  61. data/features/step_definitions/pagination_steps.rb +8 -0
  62. data/features/step_definitions/table_steps.rb +2 -1
  63. data/lib/active_admin.rb +3 -3
  64. data/lib/active_admin/application.rb +66 -16
  65. data/lib/active_admin/batch_actions.rb +0 -1
  66. data/lib/active_admin/batch_actions/controller.rb +2 -2
  67. data/lib/active_admin/batch_actions/resource_extension.rb +3 -1
  68. data/lib/active_admin/callbacks.rb +1 -1
  69. data/lib/active_admin/csv_builder.rb +2 -2
  70. data/lib/active_admin/dependency.rb +18 -16
  71. data/lib/active_admin/devise.rb +1 -1
  72. data/lib/active_admin/dsl.rb +1 -1
  73. data/lib/active_admin/event.rb +8 -17
  74. data/lib/active_admin/filters/active.rb +29 -0
  75. data/lib/active_admin/filters/forms.rb +6 -1
  76. data/lib/active_admin/filters/humanized.rb +68 -0
  77. data/lib/active_admin/filters/resource_extension.rb +48 -1
  78. data/lib/active_admin/form_builder.rb +4 -4
  79. data/lib/active_admin/generators/boilerplate.rb +37 -0
  80. data/lib/active_admin/helpers/routes/url_helpers.rb +1 -1
  81. data/lib/active_admin/inputs.rb +1 -0
  82. data/lib/active_admin/inputs/filters/date_picker_input.rb +13 -0
  83. data/lib/active_admin/inputs/filters/date_range_input.rb +1 -1
  84. data/lib/active_admin/menu.rb +1 -0
  85. data/lib/active_admin/menu_item.rb +1 -1
  86. data/lib/active_admin/namespace.rb +5 -5
  87. data/lib/active_admin/orm/active_record/comments.rb +10 -1
  88. data/lib/active_admin/orm/active_record/comments/comment.rb +1 -1
  89. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +11 -0
  90. data/lib/active_admin/resource.rb +9 -3
  91. data/lib/active_admin/resource/action_items.rb +13 -3
  92. data/lib/active_admin/resource/belongs_to.rb +6 -2
  93. data/lib/active_admin/resource/pagination.rb +4 -0
  94. data/lib/active_admin/resource_collection.rb +3 -1
  95. data/lib/active_admin/resource_controller/data_access.rb +6 -11
  96. data/lib/active_admin/resource_controller/decorators.rb +1 -1
  97. data/lib/active_admin/resource_dsl.rb +8 -2
  98. data/lib/active_admin/sidebar_section.rb +4 -12
  99. data/lib/active_admin/version.rb +1 -1
  100. data/lib/active_admin/view_factory.rb +1 -2
  101. data/lib/active_admin/view_helpers.rb +0 -1
  102. data/lib/active_admin/view_helpers/display_helper.rb +3 -4
  103. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +3 -3
  104. data/lib/active_admin/views/components/active_admin_form.rb +3 -3
  105. data/lib/active_admin/views/components/columns.rb +9 -4
  106. data/lib/active_admin/views/components/dropdown_menu.rb +0 -2
  107. data/lib/active_admin/views/components/paginated_collection.rb +35 -13
  108. data/lib/active_admin/views/components/panel.rb +1 -3
  109. data/lib/active_admin/views/components/sidebar_section.rb +6 -1
  110. data/lib/active_admin/views/components/status_tag.rb +3 -2
  111. data/lib/active_admin/views/components/table_for.rb +2 -1
  112. data/lib/active_admin/views/index_as_table.rb +2 -2
  113. data/lib/active_admin/views/pages/base.rb +4 -0
  114. data/lib/active_admin/views/pages/show.rb +1 -1
  115. data/lib/generators/active_admin/assets/assets_generator.rb +1 -1
  116. data/lib/generators/active_admin/assets/templates/{active_admin.css.scss → active_admin.scss} +0 -0
  117. data/lib/generators/active_admin/devise/devise_generator.rb +7 -19
  118. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +29 -0
  119. data/lib/generators/active_admin/page/templates/page.rb +1 -1
  120. data/lib/generators/active_admin/resource/resource_generator.rb +6 -0
  121. data/lib/generators/active_admin/resource/templates/admin.rb +34 -13
  122. data/spec/rails_helper.rb +6 -2
  123. data/spec/requests/memory_spec.rb +1 -3
  124. data/spec/support/active_admin_request_helpers.rb +27 -0
  125. data/spec/support/detect_rails_version.rb +1 -1
  126. data/spec/support/rails_template.rb +7 -0
  127. data/spec/unit/application_spec.rb +29 -4
  128. data/spec/unit/batch_actions/resource_spec.rb +5 -0
  129. data/spec/unit/belongs_to_spec.rb +14 -0
  130. data/spec/unit/comments_spec.rb +24 -2
  131. data/spec/unit/controller_filters_spec.rb +25 -28
  132. data/spec/unit/dsl_spec.rb +1 -1
  133. data/spec/unit/filters/humanized_spec.rb +56 -0
  134. data/spec/unit/filters/resource_spec.rb +1 -1
  135. data/spec/unit/form_builder_spec.rb +71 -11
  136. data/spec/unit/generators/install_spec.rb +3 -2
  137. data/spec/unit/pretty_format_spec.rb +15 -1
  138. data/spec/unit/resource_collection_spec.rb +17 -0
  139. data/spec/unit/resource_controller_spec.rb +2 -2
  140. data/spec/unit/resource_registration_spec.rb +3 -3
  141. data/spec/unit/resource_spec.rb +53 -2
  142. data/spec/unit/view_factory_spec.rb +0 -2
  143. data/spec/unit/view_helpers/display_name_spec.rb +6 -4
  144. data/spec/unit/views/components/{batch_action_popover_spec.rb → batch_action_selector_spec.rb} +9 -13
  145. data/spec/unit/views/components/columns_spec.rb +17 -0
  146. data/spec/unit/views/components/paginated_collection_spec.rb +16 -2
  147. data/spec/unit/views/components/panel_spec.rb +1 -5
  148. data/spec/unit/views/components/sidebar_section_spec.rb +21 -0
  149. data/spec/unit/views/components/status_tag_spec.rb +15 -1
  150. data/spec/unit/views/components/table_for_spec.rb +45 -0
  151. data/tasks/parallel_tests.rake +1 -1
  152. data/tasks/test.rake +4 -4
  153. metadata +29 -30
  154. data/app/assets/javascripts/active_admin/lib/popover.js.coffee +0 -68
  155. data/app/assets/stylesheets/active_admin/components/_popovers.scss +0 -122
  156. data/app/assets/stylesheets/active_admin/mixins/_icons.scss +0 -20
  157. data/lib/active_admin/batch_actions/views/batch_action_popover.rb +0 -28
  158. data/lib/active_admin/iconic.rb +0 -53
  159. data/lib/active_admin/iconic/icons.rb +0 -142
  160. data/lib/active_admin/view_helpers/icon_helper.rb +0 -12
  161. data/lib/active_admin/views/components/action_list_popover.rb +0 -29
  162. data/lib/active_admin/views/components/popover.rb +0 -27
  163. data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +0 -82
  164. data/spec/support/integration_example_group.rb +0 -31
  165. data/spec/unit/event_spec.rb +0 -47
  166. data/spec/unit/views/components/action_list_popover_spec.rb +0 -40
  167. data/spec/unit/views/components/popover_spec.rb +0 -33
@@ -42,11 +42,13 @@ module ActiveAdmin
42
42
  end
43
43
 
44
44
  def inputs(*args, &block)
45
+ if block_given?
46
+ form_builder.template.assign(has_many_block: true)
47
+ end
45
48
  if block_given? && block.arity == 0
46
49
  wrapped_block = proc do
47
50
  wrap_it = form_builder.already_in_an_inputs_block ? true : false
48
51
  form_builder.already_in_an_inputs_block = true
49
- form_builder.template.assign('has_many_block'=> true)
50
52
  content = form_builder.template.capture do
51
53
  block.call
52
54
  end
@@ -114,8 +116,6 @@ module ActiveAdmin
114
116
 
115
117
  class HasManyProxy < FormtasticProxy
116
118
  def build(form_builder, *args, &block)
117
- assoc = args[0]
118
- builder_options = args[1] || {}
119
119
  text_node form_builder.has_many(*args, &block)
120
120
  end
121
121
  end
@@ -41,7 +41,7 @@ module ActiveAdmin
41
41
  # the first being 2 time bigger than the second.
42
42
  #
43
43
  #
44
- # == Max and Mix Column Sizes
44
+ # == Max and Min Column Sizes
45
45
  #
46
46
  # Active Admin is a fluid width layout, which means that columns are all defined
47
47
  # using percentages. Sometimes this can cause issues if you don't want a column
@@ -93,19 +93,24 @@ module ActiveAdmin
93
93
  all_margins_width = margin_size * (span_count - 1)
94
94
  column_width = (100.00 - all_margins_width) / span_count
95
95
 
96
- children.each_with_index do |col, i|
96
+ columns.each_with_index do |column, i|
97
97
  is_last_column = i == (columns_count - 1)
98
- col.set_column_styles(column_width, margin_size, is_last_column)
98
+ column.set_column_styles(column_width, margin_size, is_last_column)
99
99
  end
100
100
  end
101
101
 
102
102
  def columns_span_count
103
103
  count = 0
104
- children.each {|column| count += column.span_size }
104
+ columns.each do |column|
105
+ count += column.span_size
106
+ end
105
107
 
106
108
  count
107
109
  end
108
110
 
111
+ def columns
112
+ children.select { |child| child.is_a?(Column) }
113
+ end
109
114
  end
110
115
 
111
116
  class Column < ActiveAdmin::Component
@@ -1,5 +1,3 @@
1
- require 'active_admin/views/components/popover'
2
-
3
1
  module ActiveAdmin
4
2
  module Views
5
3
 
@@ -32,11 +32,13 @@ module ActiveAdmin
32
32
  # collection => A paginated collection from kaminari
33
33
  # options => These options will be passed to `page_entries_info`
34
34
  # entry_name => The name to display for this resource collection
35
+ # params => Extra parameters for pagination (e.g. { anchor: 'details' })
35
36
  # param_name => Parameter name for page number in the links (:page by default)
36
37
  # download_links => Download links override (false or [:csv, :pdf])
37
38
  #
38
39
  def build(collection, options = {})
39
40
  @collection = collection
41
+ @params = options.delete(:params)
40
42
  @param_name = options.delete(:param_name)
41
43
  @download_links = options.delete(:download_links)
42
44
  @display_total = options.delete(:pagination_total) { true }
@@ -95,8 +97,20 @@ module ActiveAdmin
95
97
 
96
98
  def build_pagination
97
99
  options = {}
100
+ options[:params] = @params if @params
98
101
  options[:param_name] = @param_name if @param_name
99
102
 
103
+ if !@display_total && collection.respond_to?(:offset)
104
+ # The #paginate method in kaminari will query the resource with a
105
+ # count(*) to determine how many pages there should be unless
106
+ # you pass in the :total_pages option. We issue a query to determine
107
+ # if there is another page or not, but the limit/offset make this
108
+ # query fast.
109
+ offset = collection.offset(collection.current_page * @per_page.to_i).limit(1).count
110
+ options[:total_pages] = collection.current_page + offset
111
+ options[:right] = 0
112
+ end
113
+
100
114
  text_node paginate collection, options
101
115
  end
102
116
 
@@ -117,22 +131,30 @@ module ActiveAdmin
117
131
  entries_name = I18n.translate key, count: collection.size, default: entry_name.pluralize
118
132
  end
119
133
 
120
- if collection.num_pages < 2
121
- case collection_size
122
- when 0; I18n.t('active_admin.pagination.empty', model: entries_name)
123
- when 1; I18n.t('active_admin.pagination.one', model: entry_name)
124
- else; I18n.t('active_admin.pagination.one_page', model: entries_name, n: collection.total_count)
134
+ if @display_total
135
+ if collection.num_pages < 2
136
+ case collection_size
137
+ when 0; I18n.t("active_admin.pagination.empty", model: entries_name)
138
+ when 1; I18n.t("active_admin.pagination.one", model: entry_name)
139
+ else; I18n.t("active_admin.pagination.one_page", model: entries_name, n: collection.total_count)
140
+ end
141
+ else
142
+ offset = (collection.current_page - 1) * collection.limit_value
143
+ total = collection.total_count
144
+ I18n.t "active_admin.pagination.multiple",
145
+ model: entries_name,
146
+ total: total,
147
+ from: offset + 1,
148
+ to: offset + collection_size
125
149
  end
126
150
  else
151
+ # Do not display total count, in order to prevent a `SELECT count(*)`.
152
+ # To do so we must not call `collection.num_pages`
127
153
  offset = (collection.current_page - 1) * collection.limit_value
128
- if @display_total
129
- total = collection.total_count
130
- I18n.t 'active_admin.pagination.multiple', model: entries_name, total: total,
131
- from: offset + 1, to: offset + collection_size
132
- else
133
- I18n.t 'active_admin.pagination.multiple_without_total', model: entries_name,
134
- from: offset + 1, to: offset + collection_size
135
- end
154
+ I18n.t "active_admin.pagination.multiple_without_total",
155
+ model: entries_name,
156
+ from: offset + 1,
157
+ to: offset + collection_size
136
158
  end
137
159
  end
138
160
 
@@ -5,11 +5,9 @@ module ActiveAdmin
5
5
  builder_method :panel
6
6
 
7
7
  def build(title, attributes = {})
8
- icon_name = attributes.delete(:icon)
9
- icn = icon_name ? icon(icon_name) : "".html_safe
10
8
  super(attributes)
11
9
  add_class "panel"
12
- @title = h3(icn + title.to_s)
10
+ @title = h3(title.to_s)
13
11
  @contents = div(class: "panel_contents")
14
12
  end
15
13
 
@@ -7,12 +7,17 @@ module ActiveAdmin
7
7
  # Takes a ActiveAdmin::SidebarSection instance
8
8
  def build(section)
9
9
  @section = section
10
- super(@section.title, icon: @section.icon)
10
+ super(@section.title)
11
11
  add_class @section.custom_class if @section.custom_class
12
12
  self.id = @section.id
13
13
  build_sidebar_content
14
14
  end
15
15
 
16
+ # Renders attributes_table_for current resource
17
+ def attributes_table(*args, &block)
18
+ attributes_table_for resource, *args, &block
19
+ end
20
+
16
21
  protected
17
22
 
18
23
  def build_sidebar_content
@@ -57,9 +57,10 @@ module ActiveAdmin
57
57
  protected
58
58
 
59
59
  def convert_to_boolean_status(status)
60
- if status == 'true'
60
+ case status
61
+ when true, 'true'
61
62
  'Yes'
62
- elsif ['false', nil].include?(status)
63
+ when false, 'false', nil
63
64
  'No'
64
65
  else
65
66
  status
@@ -10,8 +10,9 @@ module ActiveAdmin
10
10
  def build(obj, *attrs)
11
11
  options = attrs.extract_options!
12
12
  @sortable = options.delete(:sortable)
13
- @resource_class = options.delete(:i18n)
14
13
  @collection = obj.respond_to?(:each) && !obj.is_a?(Hash) ? obj : [obj]
14
+ @resource_class = options.delete(:i18n)
15
+ @resource_class ||= @collection.klass if @collection.respond_to? :klass
15
16
  @columns = []
16
17
  @row_class = options.delete(:row_class)
17
18
 
@@ -91,7 +91,7 @@ module ActiveAdmin
91
91
  # index do
92
92
  # column :title
93
93
  # actions do |post|
94
- # a link_to "View", admin_post_path(post)
94
+ # a "View", href: admin_post_path(post)
95
95
  # end
96
96
  # end
97
97
  # ```
@@ -277,7 +277,7 @@ module ActiveAdmin
277
277
  #
278
278
  # # Append some actions onto the end of the default actions using arbre dsl.
279
279
  # actions do |admin_user|
280
- # a link_to 'Grant Admin', grant_admin_admin_user_path(admin_user)
280
+ # a 'Grant Admin', href: grant_admin_admin_user_path(admin_user)
281
281
  # end
282
282
  #
283
283
  # # Custom actions without the defaults.
@@ -35,6 +35,10 @@ module ActiveAdmin
35
35
  text_node(favicon_link_tag(active_admin_namespace.favicon))
36
36
  end
37
37
 
38
+ active_admin_namespace.meta_tags.each do |name, content|
39
+ text_node(tag(:meta, name: name, content: content))
40
+ end
41
+
38
42
  text_node csrf_meta_tag
39
43
  end
40
44
  end
@@ -35,7 +35,7 @@ module ActiveAdmin
35
35
  def default_title
36
36
  title = display_name(resource)
37
37
 
38
- if title.nil? || title.empty? || title == resource.to_s
38
+ if title.blank?
39
39
  title = "#{active_admin_config.resource_label} ##{resource.id}"
40
40
  end
41
41
 
@@ -6,7 +6,7 @@ module ActiveAdmin
6
6
 
7
7
  def install_assets
8
8
  template 'active_admin.js.coffee', 'app/assets/javascripts/active_admin.js.coffee'
9
- template 'active_admin.css.scss', 'app/assets/stylesheets/active_admin.css.scss'
9
+ template "active_admin.scss", "app/assets/stylesheets/active_admin.scss"
10
10
  end
11
11
 
12
12
  end
@@ -1,4 +1,5 @@
1
1
  require "active_admin/error"
2
+ require "active_admin/dependency"
2
3
 
3
4
  module ActiveAdmin
4
5
  module Generators
@@ -16,7 +17,7 @@ module ActiveAdmin
16
17
 
17
18
  def install_devise
18
19
  begin
19
- Dependency.devise! Dependency::DEVISE
20
+ Dependency.devise! Dependency::Requirements::DEVISE
20
21
  rescue DependencyError => e
21
22
  raise ActiveAdmin::GeneratorError, "#{e.message} If you don't want to use devise, run the generator with --skip-users."
22
23
  end
@@ -50,27 +51,14 @@ module ActiveAdmin
50
51
  gsub_file routes_file, /devise_for :#{plural_table_name}$/, "devise_for :#{plural_table_name}, ActiveAdmin::Devise.config"
51
52
  end
52
53
 
53
- def add_default_user_to_migration
54
- # Don't assume that we have a migration!
55
- devise_migration_file = Dir["db/migrate/*_devise_create_#{table_name}.rb"].first
56
- return if devise_migration_file.nil? || !options[:default_user]
57
-
58
- devise_migration_content = File.read(devise_migration_file)
54
+ def add_default_user_to_seed
55
+ seeds_paths = Rails.application.paths["db/seeds.rb"] || Rails.application.paths["db/seeds"] # "db/seeds" => Rails 3.2 fallback
56
+ seeds_file = seeds_paths.existent.first
57
+ return if seeds_file.nil? || !options[:default_user]
59
58
 
60
59
  create_user_code = "#{class_name}.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password')"
61
60
 
62
- if devise_migration_content["def change"]
63
- inject_into_file devise_migration_file,
64
- "def migrate(direction)\n super\n # Create a default user\n #{create_user_code} if direction == :up\n end\n\n ",
65
- before: "def change"
66
- elsif devise_migration_content[/def (self.)?up/]
67
- inject_into_file devise_migration_file,
68
- "# Create a default user\n #{create_user_code}\n\n ",
69
- before: "add_index :#{table_name}, :email"
70
- else
71
- puts devise_migration_content
72
- raise "Failed to add default admin user to migration."
73
- end
61
+ append_to_file seeds_file, create_user_code
74
62
  end
75
63
  end
76
64
  end
@@ -126,6 +126,10 @@ ActiveAdmin.setup do |config|
126
126
  #
127
127
  # You can change the name under which comments are registered:
128
128
  # config.comments_registration_name = 'AdminComment'
129
+ #
130
+ # You can change the order for the comments and you can change the column
131
+ # to be used for ordering
132
+ # config.comments_order = 'created_at ASC'
129
133
 
130
134
  # == Batch Actions
131
135
  #
@@ -140,10 +144,31 @@ ActiveAdmin.setup do |config|
140
144
  #
141
145
  # config.before_filter :do_something_awesome
142
146
 
147
+ # == Localize Date/Time Format
148
+ #
149
+ # Set the localize format to display dates and times.
150
+ # To understand how to localize your app with I18n, read more at
151
+ # https://github.com/svenfuchs/i18n/blob/master/lib%2Fi18n%2Fbackend%2Fbase.rb#L52
152
+ #
153
+ config.localize_format = :long
154
+
143
155
  # == Setting a Favicon
144
156
  #
145
157
  # config.favicon = 'favicon.ico'
146
158
 
159
+ # == Meta Tags
160
+ #
161
+ # Add additional meta tags to the head element of active admin pages.
162
+ #
163
+ # Add tags to all pages logged in users see:
164
+ # config.meta_tags = { author: 'My Company' }
165
+
166
+ # By default, sign up/sign in/recover password pages are excluded
167
+ # from showing up in search engine results by adding a robots meta
168
+ # tag. You can reset the hash of meta tags included in logged out
169
+ # pages:
170
+ # config.meta_tags_for_logged_out_pages = {}
171
+
147
172
  # == Removing Breadcrumbs
148
173
  #
149
174
  # Breadcrumbs are enabled by default. You can customize them for individual
@@ -222,6 +247,10 @@ ActiveAdmin.setup do |config|
222
247
  # You can control the default per page count for all resources here.
223
248
  #
224
249
  # config.default_per_page = 30
250
+ #
251
+ # You can control the max per page count too.
252
+ #
253
+ # config.max_per_page = 10_000
225
254
 
226
255
  # == Filters
227
256
  #
@@ -1,4 +1,4 @@
1
- ActiveAdmin.register_page <%= class_name %> do
1
+ ActiveAdmin.register_page "<%= class_name %>" do
2
2
  content do
3
3
  # your content
4
4
  end
@@ -1,11 +1,17 @@
1
+ require 'active_admin/generators/boilerplate'
2
+
1
3
  module ActiveAdmin
2
4
  module Generators
3
5
  class ResourceGenerator < Rails::Generators::NamedBase
4
6
  desc "Registers resources with Active Admin"
5
7
 
8
+ class_option :include_boilerplate, type: :boolean, default: false,
9
+ desc: "Generate boilerplate code for your resource."
10
+
6
11
  source_root File.expand_path("../templates", __FILE__)
7
12
 
8
13
  def generate_config_file
14
+ @boilerplate = ActiveAdmin::Generators::Boilerplate.new(class_name)
9
15
  template "admin.rb", "app/admin/#{file_path.tr('/', '_')}.rb"
10
16
  end
11
17
 
@@ -1,18 +1,39 @@
1
1
  ActiveAdmin.register <%= class_name %> do
2
-
3
2
  <% if Rails::VERSION::MAJOR == 4 || defined?(ActionController::StrongParameters) %>
4
- # See permitted parameters documentation:
5
- # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
6
- #
7
- # permit_params :list, :of, :attributes, :on, :model
8
- #
9
- # or
10
- #
11
- # permit_params do
12
- # permitted = [:permitted, :attributes]
13
- # permitted << :other if resource.something?
14
- # permitted
15
- # end
3
+ # See permitted parameters documentation:
4
+ # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
5
+ #
6
+ # permit_params :list, :of, :attributes, :on, :model
7
+ #
8
+ # or
9
+ #
10
+ # permit_params do
11
+ # permitted = [:permitted, :attributes]
12
+ # permitted << :other if resource.something?
13
+ # permitted
14
+ # end
16
15
  <% end %>
16
+ <% if options.include_boilerplate? %>
17
+ # Limit actions available to your users by adding them to the 'except' array
18
+ # actions :all, except: []
19
+
20
+ # Add or remove filters (you can use any ActiveRecord scope) to toggle their
21
+ # visibility in the sidebar
22
+ <%= @boilerplate.filters %>
23
+
24
+ # Add or remove columns to toggle their visiblity in the index action
25
+ # index do
26
+ # selectable_column
27
+ # id_column
28
+ <%= @boilerplate.columns %>
29
+ # actions
30
+ # end
17
31
 
32
+ # Add or remove rows to toggle their visiblity in the show action
33
+ # show do |<%= class_name.downcase %>|
34
+ <%= @boilerplate.rows %>
35
+ # end
36
+
37
+ # Add or remove fields to toggle their visibility in the form
38
+ <% end %>
18
39
  end
@@ -107,6 +107,10 @@ require ENV['RAILS_ROOT'] + '/config/environment'
107
107
 
108
108
  require 'rspec/rails'
109
109
 
110
+ # Prevent Test::Unit's AutoRunner from executing during RSpec's rake task on
111
+ # JRuby
112
+ Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
113
+
110
114
  # Setup Some Admin stuff for us to play with
111
115
  include ActiveAdminIntegrationSpecHelper
112
116
  load_defaults!
@@ -133,9 +137,9 @@ end
133
137
 
134
138
  # All RSpec configuration needs to happen before any examples
135
139
  # or else it whines.
136
- require 'integration_example_group'
140
+ require "support/active_admin_request_helpers"
137
141
  RSpec.configure do |c|
138
- c.include RSpec::Rails::IntegrationExampleGroup, file_path: /\bspec\/requests\//
142
+ c.include ActiveAdminRequestHelpers, type: :request
139
143
  c.include Devise::TestHelpers, type: :controller
140
144
  end
141
145