Class: Madmin::Fields::NestedHasMany
- Inherits:
-
HasMany
show all
- Defined in:
- lib/madmin/fields/nested_has_many.rb
Constant Summary
collapse
- DEFAULT_ATTRIBUTES =
%w[_destroy id].freeze
Instance Attribute Summary
#attribute_name, #model, #options
Instance Method Summary
collapse
Methods inherited from HasMany
#associated_resource, #associated_resource_for, #index_path, #options_for_select, #paginated_value
#default_index_attributes, field_type, #initialize, #required?, #searchable?, #value, #visible?
Constructor Details
This class inherits a constructor from Madmin::Field
Instance Method Details
#nested_attributes ⇒ Object
5
6
7
|
# File 'lib/madmin/fields/nested_has_many.rb', line 5
def nested_attributes
resource.attributes.except(*skipped_fields)
end
|
#paginateable? ⇒ Boolean
29
30
31
|
# File 'lib/madmin/fields/nested_has_many.rb', line 29
def paginateable?
true
end
|
#resource ⇒ Object
9
10
11
|
# File 'lib/madmin/fields/nested_has_many.rb', line 9
def resource
"#{to_model.name}Resource".constantize
end
|
#to_model ⇒ Object
25
26
27
|
# File 'lib/madmin/fields/nested_has_many.rb', line 25
def to_model
attribute_name.to_s.singularize.classify.constantize
end
|
#to_param ⇒ Object
13
14
15
|
# File 'lib/madmin/fields/nested_has_many.rb', line 13
def to_param
{"#{attribute_name}_attributes": permitted_fields}
end
|
#to_partial_path(name) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/madmin/fields/nested_has_many.rb', line 17
def to_partial_path(name)
unless %w[index show form fields].include? name
raise ArgumentError, "`partial` must be 'index', 'show', 'form' or 'fields'"
end
"/madmin/fields/#{self.class.field_type}/#{name}"
end
|