activeadmin 1.4.3 → 2.0.0.rc1

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 (164) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +70 -10
  3. data/CONTRIBUTING.md +12 -11
  4. data/README.md +34 -8
  5. data/app/assets/javascripts/active_admin/base.es6 +23 -0
  6. data/app/assets/javascripts/active_admin/ext/jquery-ui.es6 +7 -0
  7. data/app/assets/javascripts/active_admin/ext/jquery.es6 +9 -0
  8. data/app/assets/javascripts/active_admin/initializers/datepicker.es6 +16 -0
  9. data/app/assets/javascripts/active_admin/initializers/filters.es6 +45 -0
  10. data/app/assets/javascripts/active_admin/initializers/tabs.es6 +6 -0
  11. data/app/assets/javascripts/active_admin/lib/active_admin.es6 +41 -0
  12. data/app/assets/javascripts/active_admin/lib/batch_actions.es6 +55 -0
  13. data/app/assets/javascripts/active_admin/lib/checkbox-toggler.es6 +49 -0
  14. data/app/assets/javascripts/active_admin/lib/dropdown-menu.es6 +123 -0
  15. data/app/assets/javascripts/active_admin/lib/has_many.es6 +95 -0
  16. data/app/assets/javascripts/active_admin/lib/modal_dialog.es6 +61 -0
  17. data/app/assets/javascripts/active_admin/lib/per_page.es6 +47 -0
  18. data/app/assets/javascripts/active_admin/lib/table-checkbox-toggler.es6 +36 -0
  19. data/app/assets/stylesheets/active_admin/_forms.scss +2 -14
  20. data/app/assets/stylesheets/active_admin/components/_status_tags.scss +0 -5
  21. data/app/assets/stylesheets/active_admin/components/_tabs.scss +1 -1
  22. data/app/assets/stylesheets/active_admin/mixins/_gradients.scss +1 -1
  23. data/app/views/active_admin/devise/confirmations/new.html.erb +1 -1
  24. data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
  25. data/app/views/active_admin/devise/passwords/new.html.erb +1 -1
  26. data/app/views/active_admin/devise/registrations/new.html.erb +1 -2
  27. data/app/views/active_admin/devise/shared/_error_messages.html.erb +15 -0
  28. data/app/views/active_admin/devise/unlocks/new.html.erb +1 -1
  29. data/app/views/layouts/active_admin_logged_out.html.erb +1 -1
  30. data/config/locales/bg.yml +0 -1
  31. data/config/locales/he.yml +0 -1
  32. data/config/locales/hu.yml +4 -0
  33. data/config/locales/lt.yml +2 -2
  34. data/config/locales/uk.yml +2 -0
  35. data/docs/0-installation.md +2 -2
  36. data/docs/13-authorization-adapter.md +4 -4
  37. data/docs/CNAME +1 -1
  38. data/docs/index.html +2 -2
  39. data/lib/active_admin.rb +9 -4
  40. data/lib/active_admin/application.rb +8 -14
  41. data/lib/active_admin/application_settings.rb +3 -0
  42. data/lib/active_admin/asset_registration.rb +0 -8
  43. data/lib/active_admin/base_controller.rb +6 -6
  44. data/lib/active_admin/base_controller/authorization.rb +2 -4
  45. data/lib/active_admin/batch_actions/controller.rb +1 -1
  46. data/lib/active_admin/batch_actions/resource_extension.rb +4 -4
  47. data/lib/active_admin/callbacks.rb +1 -1
  48. data/lib/active_admin/csv_builder.rb +1 -1
  49. data/lib/active_admin/dependency.rb +1 -77
  50. data/lib/active_admin/dsl.rb +1 -8
  51. data/lib/active_admin/error.rb +1 -1
  52. data/lib/active_admin/filters/active_filter.rb +3 -1
  53. data/lib/active_admin/filters/active_sidebar.rb +5 -1
  54. data/lib/active_admin/filters/forms.rb +2 -2
  55. data/lib/active_admin/filters/formtastic_addons.rb +1 -1
  56. data/lib/active_admin/filters/resource_extension.rb +3 -3
  57. data/lib/active_admin/form_builder.rb +3 -3
  58. data/lib/active_admin/generators/boilerplate.rb +1 -1
  59. data/lib/active_admin/helpers/scope_chain.rb +1 -0
  60. data/lib/active_admin/inputs/datepicker_input.rb +1 -1
  61. data/lib/active_admin/inputs/filters/base/search_method_select.rb +2 -2
  62. data/lib/active_admin/menu_item.rb +1 -1
  63. data/lib/active_admin/namespace.rb +2 -2
  64. data/lib/active_admin/namespace_settings.rb +7 -4
  65. data/lib/active_admin/orm/active_record/comments.rb +4 -4
  66. data/lib/active_admin/orm/active_record/comments/comment.rb +2 -2
  67. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +10 -5
  68. data/lib/active_admin/page_dsl.rb +1 -1
  69. data/lib/active_admin/pundit_adapter.rb +13 -4
  70. data/lib/active_admin/resource.rb +2 -2
  71. data/lib/active_admin/resource/action_items.rb +1 -1
  72. data/lib/active_admin/resource/attributes.rb +7 -4
  73. data/lib/active_admin/resource/menu.rb +3 -3
  74. data/lib/active_admin/resource/naming.rb +3 -3
  75. data/lib/active_admin/resource/routes.rb +9 -4
  76. data/lib/active_admin/resource/scopes.rb +3 -3
  77. data/lib/active_admin/resource/sidebars.rb +1 -1
  78. data/lib/active_admin/resource_collection.rb +2 -2
  79. data/lib/active_admin/resource_controller/action_builder.rb +10 -0
  80. data/lib/active_admin/resource_controller/resource_class_methods.rb +2 -0
  81. data/lib/active_admin/resource_dsl.rb +5 -3
  82. data/lib/active_admin/router.rb +1 -1
  83. data/lib/active_admin/scope.rb +4 -4
  84. data/lib/active_admin/settings_node.rb +1 -1
  85. data/lib/active_admin/version.rb +1 -1
  86. data/lib/active_admin/view_helpers.rb +1 -1
  87. data/lib/active_admin/view_helpers/display_helper.rb +10 -2
  88. data/lib/active_admin/view_helpers/download_format_links_helper.rb +1 -0
  89. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +2 -0
  90. data/lib/active_admin/views.rb +1 -1
  91. data/lib/active_admin/views/components/active_admin_form.rb +7 -1
  92. data/lib/active_admin/views/components/attributes_table.rb +3 -3
  93. data/lib/active_admin/views/components/paginated_collection.rb +1 -1
  94. data/lib/active_admin/views/components/sidebar_section.rb +0 -3
  95. data/lib/active_admin/views/components/status_tag.rb +1 -18
  96. data/lib/active_admin/views/components/table_for.rb +2 -2
  97. data/lib/active_admin/views/components/tabs.rb +11 -2
  98. data/lib/active_admin/views/footer.rb +1 -1
  99. data/lib/active_admin/views/index_as_table.rb +5 -4
  100. data/lib/active_admin/views/pages/base.rb +3 -0
  101. data/lib/generators/active_admin/assets/assets_generator.rb +2 -2
  102. data/lib/generators/active_admin/assets/templates/active_admin.js +1 -0
  103. data/lib/generators/active_admin/install/install_generator.rb +6 -2
  104. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +20 -1
  105. data/lib/generators/active_admin/install/templates/dashboard.rb +2 -3
  106. data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb.erb +1 -15
  107. data/lib/generators/active_admin/page/page_generator.rb +1 -1
  108. data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
  109. data/lib/ransack_ext.rb +3 -3
  110. data/vendor/assets/javascripts/jquery-ui/form-reset-mixin.js +80 -0
  111. data/vendor/assets/javascripts/jquery-ui/form.js +22 -0
  112. data/vendor/assets/javascripts/jquery-ui/labels.js +65 -0
  113. data/vendor/assets/javascripts/jquery-ui/widgets/checkboxradio.js +274 -283
  114. metadata +107 -96
  115. data/.circleci/config.yml +0 -572
  116. data/.github/ISSUE_TEMPLATE.md +0 -20
  117. data/.gitignore +0 -16
  118. data/.mdlrc +0 -1
  119. data/.rspec +0 -1
  120. data/.rspec_parallel +0 -2
  121. data/.rubocop.yml +0 -99
  122. data/.simplecov +0 -9
  123. data/.yardopts +0 -7
  124. data/Gemfile +0 -30
  125. data/Gemfile.common +0 -26
  126. data/Gemfile.lock +0 -433
  127. data/Rakefile +0 -24
  128. data/activeadmin.gemspec +0 -32
  129. data/app/assets/javascripts/active_admin/base.js.coffee +0 -13
  130. data/app/assets/javascripts/active_admin/ext/jquery-ui.js.coffee +0 -6
  131. data/app/assets/javascripts/active_admin/ext/jquery.js.coffee +0 -7
  132. data/app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee +0 -11
  133. data/app/assets/javascripts/active_admin/initializers/datepicker.js.coffee +0 -14
  134. data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +0 -26
  135. data/app/assets/javascripts/active_admin/initializers/tabs.js.coffee +0 -7
  136. data/app/assets/javascripts/active_admin/lib/batch_actions.js.coffee +0 -42
  137. data/app/assets/javascripts/active_admin/lib/checkbox-toggler.js.coffee +0 -46
  138. data/app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee +0 -104
  139. data/app/assets/javascripts/active_admin/lib/flash.js.coffee +0 -19
  140. data/app/assets/javascripts/active_admin/lib/has_many.js.coffee +0 -79
  141. data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +0 -45
  142. data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +0 -46
  143. data/app/assets/javascripts/active_admin/lib/table-checkbox-toggler.js.coffee +0 -22
  144. data/bin/install_chromedriver.sh +0 -17
  145. data/config/i18n-tasks.yml +0 -26
  146. data/config/mdl_style.rb +0 -11
  147. data/cucumber.yml +0 -7
  148. data/gemfiles/rails_42.gemfile +0 -10
  149. data/gemfiles/rails_42.gemfile.lock +0 -339
  150. data/gemfiles/rails_50.gemfile +0 -10
  151. data/gemfiles/rails_50.gemfile.lock +0 -353
  152. data/gemfiles/rails_51.gemfile +0 -10
  153. data/gemfiles/rails_51.gemfile.lock +0 -353
  154. data/lib/active_admin/event.rb +0 -24
  155. data/lib/active_admin/helpers/output_safety_helper.rb +0 -35
  156. data/lib/bug_report_templates/active_admin_master.rb +0 -111
  157. data/lib/generators/active_admin/assets/templates/active_admin.js.coffee +0 -1
  158. data/tasks/application_generator.rb +0 -50
  159. data/tasks/docs.rake +0 -64
  160. data/tasks/gemfiles.rake +0 -8
  161. data/tasks/lint.rake +0 -110
  162. data/tasks/local.rake +0 -27
  163. data/tasks/release.rake +0 -6
  164. data/tasks/test.rake +0 -42
@@ -21,7 +21,7 @@ module ActiveAdmin
21
21
  def page_action(name, options = {}, &block)
22
22
  config.page_actions << ControllerAction.new(name, options)
23
23
  controller do
24
- define_method(name, &block || Proc.new{})
24
+ define_method(name, &block || Proc.new {})
25
25
  end
26
26
  end
27
27
 
@@ -4,6 +4,7 @@ require 'pundit'
4
4
 
5
5
  # Add a setting to the application to configure the pundit default policy
6
6
  ActiveAdmin::Application.inheritable_setting :pundit_default_policy, nil
7
+ ActiveAdmin::Application.inheritable_setting :pundit_policy_namespace, nil
7
8
 
8
9
  module ActiveAdmin
9
10
 
@@ -19,7 +20,7 @@ module ActiveAdmin
19
20
  def scope_collection(collection, action = Auth::READ)
20
21
  # scoping is appliable only to read/index action
21
22
  # which means there is no way how to scope other actions
22
- Pundit.policy_scope!(user, collection)
23
+ Pundit.policy_scope!(user, namespace(collection))
23
24
  rescue Pundit::NotDefinedError => e
24
25
  if default_policy_class && default_policy_class.const_defined?(:Scope)
25
26
  default_policy_class::Scope.new(user, collection).resolve
@@ -30,9 +31,9 @@ module ActiveAdmin
30
31
 
31
32
  def retrieve_policy(subject)
32
33
  case subject
33
- when nil then Pundit.policy!(user, resource)
34
- when Class then Pundit.policy!(user, subject.new)
35
- else Pundit.policy!(user, subject)
34
+ when nil then Pundit.policy!(user, namespace(resource))
35
+ when Class then Pundit.policy!(user, namespace(subject.new))
36
+ else Pundit.policy!(user, namespace(subject))
36
37
  end
37
38
  rescue Pundit::NotDefinedError => e
38
39
  if default_policy_class
@@ -55,6 +56,14 @@ module ActiveAdmin
55
56
 
56
57
  private
57
58
 
59
+ def namespace(object)
60
+ if ActiveAdmin.application.pundit_policy_namespace
61
+ [ActiveAdmin.application.pundit_policy_namespace.to_sym, object]
62
+ else
63
+ object
64
+ end
65
+ end
66
+
58
67
  def default_policy_class
59
68
  ActiveAdmin.application.pundit_default_policy && ActiveAdmin.application.pundit_default_policy.constantize
60
69
  end
@@ -181,11 +181,11 @@ module ActiveAdmin
181
181
  end
182
182
 
183
183
  def association_columns
184
- @association_columns ||= resource_attributes.select{ |key, value| key != value }.values
184
+ @association_columns ||= resource_attributes.select { |key, value| key != value }.values
185
185
  end
186
186
 
187
187
  def content_columns
188
- @content_columns ||= resource_attributes.select{ |key, value| key == value }.values
188
+ @content_columns ||= resource_attributes.select { |key, value| key == value }.values
189
189
  end
190
190
 
191
191
  private
@@ -87,7 +87,7 @@ module ActiveAdmin
87
87
  if controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, resource)
88
88
  localizer = ActiveAdmin::Localizers.resource(active_admin_config)
89
89
  link_to localizer.t(:delete_model), resource_path(resource), method: :delete,
90
- data: {confirm: localizer.t(:delete_confirmation)}
90
+ data: { confirm: localizer.t(:delete_confirmation) }
91
91
  end
92
92
  end
93
93
  end
@@ -18,13 +18,13 @@ module ActiveAdmin
18
18
 
19
19
  def foreign_methods
20
20
  @foreign_methods ||= resource_class.reflect_on_all_associations.
21
- select{ |r| r.macro == :belongs_to }.
22
- reject{ |r| r.chain.length > 2 && !r.options[:polymorphic] }.
23
- index_by{ |r| r.foreign_key.to_sym }
21
+ select { |r| r.macro == :belongs_to }.
22
+ reject { |r| r.chain.length > 2 && !r.options[:polymorphic] }.
23
+ index_by { |r| r.foreign_key.to_sym }
24
24
  end
25
25
 
26
26
  def reject_col?(c)
27
- primary_col?(c) || sti_col?(c) || counter_cache_col?(c)
27
+ primary_col?(c) || sti_col?(c) || counter_cache_col?(c) || filtered_col?(c)
28
28
  end
29
29
 
30
30
  def primary_col?(c)
@@ -39,6 +39,9 @@ module ActiveAdmin
39
39
  c.name.end_with?('_count')
40
40
  end
41
41
 
42
+ def filtered_col?(c)
43
+ ActiveAdmin.application.filter_attributes.include?(c.name.to_sym)
44
+ end
42
45
  end
43
46
  end
44
47
  end
@@ -26,9 +26,9 @@ module ActiveAdmin
26
26
  resource = self
27
27
  {
28
28
  id: resource_name.plural,
29
- label: proc{ resource.plural_resource_label },
30
- url: proc{ resource.route_collection_path(params, url_options) },
31
- if: proc{ authorized?(Auth::READ, menu_resource_class) }
29
+ label: proc { resource.plural_resource_label },
30
+ url: proc { resource.route_collection_path(params, url_options) },
31
+ if: proc { authorized?(Auth::READ, menu_resource_class) }
32
32
  }
33
33
  end
34
34
 
@@ -22,8 +22,8 @@ module ActiveAdmin
22
22
 
23
23
  # Returns the plural version of this resource such as "Bank Accounts"
24
24
  def plural_resource_label(options = {})
25
- defaults = {count: Helpers::I18n::PLURAL_MANY_COUNT,
26
- default: resource_label.pluralize.titleize}
25
+ defaults = { count: Helpers::I18n::PLURAL_MANY_COUNT,
26
+ default: resource_label.pluralize.titleize }
27
27
  resource_name.translate defaults.merge options
28
28
  end
29
29
 
@@ -46,7 +46,7 @@ module ActiveAdmin
46
46
  end
47
47
 
48
48
  def translate(options = {})
49
- I18n.t i18n_key, {scope: [:activerecord, :models]}.merge(options)
49
+ I18n.t i18n_key, { scope: [:activerecord, :models] }.merge(options)
50
50
  end
51
51
 
52
52
  def route_key
@@ -20,7 +20,11 @@ module ActiveAdmin
20
20
  end
21
21
 
22
22
  def route_edit_instance_path(resource, additional_params = {})
23
- route_builder.edit_instance_path(resource, additional_params)
23
+ route_builder.member_action_path(:edit, resource, additional_params)
24
+ end
25
+
26
+ def route_member_action_path(action, resource, additional_params = {})
27
+ route_builder.member_action_path(action, resource, additional_params)
24
28
  end
25
29
 
26
30
  # Returns the routes prefix for this config
@@ -75,12 +79,13 @@ module ActiveAdmin
75
79
  routes.public_send route_name, *route_instance_params(instance), additional_params
76
80
  end
77
81
 
78
- # @return [String] the path to the edit page of this resource
82
+ # @return [String] the path to the member action of this resource
83
+ # @param action [Symbol]
79
84
  # @param instance [ActiveRecord::Base] the instance we want the path of
80
85
  # @example "/admin/posts/1/edit"
81
- def edit_instance_path(instance, additional_params = {})
86
+ def member_action_path(action, instance, additional_params = {})
82
87
  path = resource.resources_configuration[:self][:route_instance_name]
83
- route_name = route_name(path, action: :edit)
88
+ route_name = route_name(path, action: action)
84
89
 
85
90
  routes.public_send route_name, *route_instance_params(instance), additional_params
86
91
  end
@@ -10,7 +10,7 @@ module ActiveAdmin
10
10
  # Returns a scope for this object by its identifier
11
11
  def get_scope_by_id(id)
12
12
  id = id.to_s
13
- scopes.find{|s| s.id == id }
13
+ scopes.find { |s| s.id == id }
14
14
  end
15
15
 
16
16
  def default_scope(context = nil)
@@ -27,7 +27,7 @@ module ActiveAdmin
27
27
  # If you want to internationalize the scope name, you can add
28
28
  # to your i18n files a key like "active_admin.scopes.scope_method".
29
29
  def scope(*args, &block)
30
- default_options = {show_count: namespace.scopes_show_count}
30
+ default_options = { show_count: namespace.scopes_show_count }
31
31
  options = default_options.merge(args.extract_options!)
32
32
  title = args[0] rescue nil
33
33
  method = args[1] rescue nil
@@ -36,7 +36,7 @@ module ActiveAdmin
36
36
  scope = ActiveAdmin::Scope.new(title, method, options, &block)
37
37
 
38
38
  # Finds and replaces a scope by the same name if it already exists
39
- existing_scope_index = scopes.index{|existing_scope| existing_scope.id == scope.id }
39
+ existing_scope_index = scopes.index { |existing_scope| existing_scope.id == scope.id }
40
40
  if existing_scope_index
41
41
  scopes.delete_at(existing_scope_index)
42
42
  scopes.insert(existing_scope_index, scope)
@@ -14,7 +14,7 @@ module ActiveAdmin
14
14
  end
15
15
 
16
16
  def sidebar_sections_for(action, render_context = nil)
17
- sidebar_sections.select{|section| section.display_on?(action, render_context) }
17
+ sidebar_sections.select { |section| section.display_on?(action, render_context) }
18
18
  .sort_by(&:priority)
19
19
  end
20
20
 
@@ -38,12 +38,12 @@ module ActiveAdmin
38
38
  r.resource_class.to_s == obj.to_s
39
39
  end ||
40
40
  if obj.respond_to? :base_class
41
- resources.detect{ |r| r.resource_class.to_s == obj.base_class.to_s }
41
+ resources.detect { |r| r.resource_class.to_s == obj.base_class.to_s }
42
42
  end
43
43
  end
44
44
 
45
45
  def resources
46
- select{ |r| r.class <= Resource } # can otherwise be a Page
46
+ select { |r| r.class <= Resource } # can otherwise be a Page
47
47
  end
48
48
 
49
49
  def raise_if_mismatched!(existing, given)
@@ -7,12 +7,22 @@ module ActiveAdmin
7
7
  module ClassMethods
8
8
 
9
9
  def clear_member_actions!
10
+ remove_action_methods(:member)
10
11
  active_admin_config.clear_member_actions!
11
12
  end
12
13
 
13
14
  def clear_collection_actions!
15
+ remove_action_methods(:collection)
14
16
  active_admin_config.clear_collection_actions!
15
17
  end
18
+
19
+ private
20
+
21
+ def remove_action_methods(actions_type)
22
+ active_admin_config.public_send("#{actions_type}_actions").each do |action|
23
+ remove_method action.name
24
+ end
25
+ end
16
26
  end
17
27
 
18
28
  end
@@ -13,6 +13,8 @@ module ActiveAdmin
13
13
  @active_admin_config ? @active_admin_config.resource_class : nil
14
14
  end
15
15
 
16
+ private
17
+
16
18
  def resource_class
17
19
  self.class.resource_class
18
20
  end
@@ -74,6 +74,8 @@ module ActiveAdmin
74
74
 
75
75
  params.permit(*permitted_params, param_key => block ? instance_exec(&block) : args)
76
76
  end
77
+
78
+ private :permitted_params
77
79
  end
78
80
  end
79
81
 
@@ -119,7 +121,7 @@ module ActiveAdmin
119
121
  #
120
122
  # ActiveAdmin.register Post do
121
123
  # member_action :comments do
122
- # @post = Post.find(params[:id]
124
+ # @post = Post.find(params[:id])
123
125
  # @comments = @post.comments
124
126
  # end
125
127
  # end
@@ -138,7 +140,7 @@ module ActiveAdmin
138
140
 
139
141
  controller do
140
142
  before_action(only: [name]) { @page_title = title } if title
141
- define_method(name, &block || Proc.new{})
143
+ define_method(name, &block || Proc.new {})
142
144
  end
143
145
  end
144
146
 
@@ -187,7 +189,7 @@ module ActiveAdmin
187
189
  delegate :before_save, :after_save, to: :controller
188
190
  delegate :before_destroy, :after_destroy, to: :controller
189
191
 
190
- # This code defines both *_filter and *_action for Rails 4.0 to Rails 5 and *_action for Rails >= 5.1
192
+ # This code defines both *_filter and *_action for Rails 5.0 and *_action for Rails >= 5.1
191
193
  phases = [
192
194
  :before, :skip_before,
193
195
  :after, :skip_after,
@@ -28,7 +28,7 @@ module ActiveAdmin
28
28
 
29
29
  # Defines the routes for each resource
30
30
  def define_resources_routes
31
- resources = namespaces.flat_map{ |n| n.resources.values }
31
+ resources = namespaces.flat_map { |n| n.resources.values }
32
32
  resources.each do |config|
33
33
  define_resource_routes(config)
34
34
  end
@@ -32,10 +32,10 @@ module ActiveAdmin
32
32
 
33
33
  if name.is_a? Proc
34
34
  raise "A string/symbol is required as the second argument if your label is a proc." unless method
35
- @id = ActiveAdmin::Dependency.rails.parameterize method.to_s
35
+ @id = method.to_s.parameterize(separator: "_")
36
36
  else
37
37
  @scope_method ||= name.to_sym
38
- @id = ActiveAdmin::Dependency.rails.parameterize name.to_s
38
+ @id = name.to_s.parameterize(separator: "_")
39
39
  end
40
40
 
41
41
  @scope_method = nil if @scope_method == :all
@@ -43,8 +43,8 @@ module ActiveAdmin
43
43
 
44
44
  @localizer = options[:localizer]
45
45
  @show_count = options.fetch(:show_count, true)
46
- @display_if_block = options[:if] || proc{ true }
47
- @default_block = options[:default] || proc{ false }
46
+ @display_if_block = options[:if] || proc { true }
47
+ @default_block = options[:default] || proc { false }
48
48
  @group = options[:group].try(:to_sym)
49
49
  end
50
50
 
@@ -5,7 +5,7 @@ module ActiveAdmin
5
5
  # Never instantiated. Variables are stored in the singleton_class.
6
6
  private_class_method :new
7
7
 
8
- # @returns anonymous class with same accessors as the superclass.
8
+ # @return anonymous class with same accessors as the superclass.
9
9
  def build(superclass = self)
10
10
  Class.new(superclass)
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveAdmin
2
- VERSION = '1.4.3'
2
+ VERSION = '2.0.0.rc1'
3
3
  end
@@ -2,7 +2,7 @@ module ActiveAdmin
2
2
  module ViewHelpers
3
3
 
4
4
  # Require all ruby files in the view helpers dir
5
- Dir[File.expand_path('../view_helpers', __FILE__) + "/*.rb"].each{|f| require f }
5
+ Dir[File.expand_path('view_helpers', __dir__) + "/*.rb"].each { |f| require f }
6
6
 
7
7
  include ActiveAdminApplicationHelper
8
8
  include AutoLinkHelper
@@ -2,7 +2,7 @@ module ActiveAdmin
2
2
  module ViewHelpers
3
3
  module DisplayHelper
4
4
 
5
- DISPLAY_NAME_FALLBACK = ->{
5
+ DISPLAY_NAME_FALLBACK = -> {
6
6
  name, klass = "", self.class
7
7
  name << klass.model_name.human if klass.respond_to? :model_name
8
8
  name << " ##{send(klass.primary_key)}" if klass.respond_to? :primary_key
@@ -25,7 +25,7 @@ module ActiveAdmin
25
25
  @@display_name_methods_cache ||= {}
26
26
  @@display_name_methods_cache[resource.class] ||= begin
27
27
  methods = active_admin_application.display_name_methods - association_methods_for(resource)
28
- method = methods.detect{ |method| resource.respond_to? method }
28
+ method = methods.detect { |method| resource.respond_to? method }
29
29
 
30
30
  if method != :to_s || resource.method(method).source_location
31
31
  method
@@ -69,16 +69,24 @@ module ActiveAdmin
69
69
  object.to_s
70
70
  when Date, Time
71
71
  I18n.localize object, format: active_admin_application.localize_format
72
+ when Array
73
+ format_collection(object)
72
74
  else
73
75
  if defined?(::ActiveRecord) && object.is_a?(ActiveRecord::Base) ||
74
76
  defined?(::Mongoid) && object.class.include?(Mongoid::Document)
75
77
  auto_link object
78
+ elsif defined?(::ActiveRecord) && object.is_a?(ActiveRecord::Relation)
79
+ format_collection(object)
76
80
  else
77
81
  display_name object
78
82
  end
79
83
  end
80
84
  end
81
85
 
86
+ def format_collection(collection)
87
+ safe_join(collection.map { |item| pretty_format(item) }, ', ')
88
+ end
89
+
82
90
  def boolean_attr?(resource, attr, value)
83
91
  case value
84
92
  when TrueClass, FalseClass
@@ -1,6 +1,7 @@
1
1
  module ActiveAdmin
2
2
  module ViewHelpers
3
3
  module DownloadFormatLinksHelper
4
+ private
4
5
 
5
6
  def build_download_formats(download_links)
6
7
  download_links = instance_exec(&download_links) if download_links.is_a?(Proc)
@@ -1,3 +1,5 @@
1
+ # Utility methods for internal use.
2
+ # @private
1
3
  module MethodOrProcHelper
2
4
  extend self
3
5
 
@@ -2,7 +2,7 @@ module ActiveAdmin
2
2
  module Views
3
3
 
4
4
  # Loads all the classes in views/*.rb
5
- Dir[File.expand_path('../views', __FILE__) + "/**/*.rb"].sort.each{ |f| require f }
5
+ Dir[File.expand_path('views', __dir__) + "/**/*.rb"].sort.each { |f| require f }
6
6
 
7
7
  end
8
8
  end
@@ -57,6 +57,12 @@ module ActiveAdmin
57
57
  end
58
58
  insert_tag(SemanticInputsProxy, form_builder, *args, &wrapped_block)
59
59
  else
60
+ # Set except option to prevent sensitive fields from being shown in forms by default.
61
+ opts = args.extract_options!
62
+ opts[:except] ||= []
63
+ ActiveAdmin.application.filter_attributes.each { |e| opts[:except] << e }
64
+ args << opts
65
+
60
66
  proxy_call_to_form(:inputs, *args, &block)
61
67
  end
62
68
  end
@@ -125,7 +131,7 @@ module ActiveAdmin
125
131
  legend = args.shift if args.first.is_a?(::String)
126
132
  legend = html_options.delete(:name) if html_options.key?(:name)
127
133
  legend_tag = legend ? "<legend><span>#{legend}</span></legend>" : ""
128
- fieldset_attrs = html_options.map {|k, v| %Q{#{k}="#{v}"} }.join(" ")
134
+ fieldset_attrs = html_options.map { |k, v| %Q{#{k}="#{v}"} }.join(" ")
129
135
  @opening_tag = "<fieldset #{fieldset_attrs}>#{legend_tag}<ol>"
130
136
  @closing_tag = "</ol></fieldset>"
131
137
  super(*(args << html_options), &block)
@@ -7,7 +7,7 @@ module ActiveAdmin
7
7
  def build(obj, *attrs)
8
8
  @collection = Array.wrap(obj)
9
9
  @resource_class = @collection.first.class
10
- options = { }
10
+ options = {}
11
11
  options[:for] = @collection.first if single_record?
12
12
  super(options)
13
13
  @table = table
@@ -16,7 +16,7 @@ module ActiveAdmin
16
16
  end
17
17
 
18
18
  def rows(*attrs)
19
- attrs.each {|attr| row(attr) }
19
+ attrs.each { |attr| row(attr) }
20
20
  end
21
21
 
22
22
  def row(*args, &block)
@@ -26,7 +26,7 @@ module ActiveAdmin
26
26
  if options[:class]
27
27
  classes << options[:class]
28
28
  elsif title.present?
29
- classes << "row-#{ActiveAdmin::Dependency.rails.parameterize(title.to_s)}"
29
+ classes << "row-#{title.to_s.parameterize(separator: "_")}"
30
30
  end
31
31
  options[:class] = classes.join(' ')
32
32