Module: ActiveAdmin::Resource::Naming
- Included in:
- Page, ActiveAdmin::Resource
- Defined in:
- lib/active_admin/resource/naming.rb
Instance Method Summary collapse
-
#param_key ⇒ Object
Forms use the model’s original ‘param_key`, so we can’t use our custom ‘resource_name` when the model’s been renamed in ActiveAdmin.
-
#plural_resource_label(options = {}) ⇒ Object
Returns the plural version of this resource such as “Bank Accounts”.
-
#resource_label ⇒ Object
Returns the name to call this resource such as “Bank Account”.
- #resource_name ⇒ Object
Instance Method Details
#param_key ⇒ Object
Forms use the model’s original ‘param_key`, so we can’t use our custom ‘resource_name` when the model’s been renamed in ActiveAdmin.
32 33 34 35 36 37 38 |
# File 'lib/active_admin/resource/naming.rb', line 32 def param_key if resource_class.respond_to? :model_name resource_class.model_name.param_key else resource_name.param_key end end |
#plural_resource_label(options = {}) ⇒ Object
Returns the plural version of this resource such as “Bank Accounts”
25 26 27 28 |
# File 'lib/active_admin/resource/naming.rb', line 25 def plural_resource_label( = {}) defaults = { count: 2.1, default: resource_label.pluralize.titleize } resource_name.translate defaults.merge end |
#resource_label ⇒ Object
Returns the name to call this resource such as “Bank Account”
19 20 21 22 |
# File 'lib/active_admin/resource/naming.rb', line 19 def resource_label resource_name.translate count: 1, default: resource_name.to_s.gsub("::", " ").titleize end |
#resource_name ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/active_admin/resource/naming.rb', line 6 def resource_name @resource_name ||= begin as = @options[:as].gsub /\s/, "" if @options[:as] if as || !resource_class.respond_to?(:model_name) Name.new resource_class, as else Name.new resource_class end end end |