Class: Madmin::Fields::NestedHasMany
Constant Summary
collapse
- DEFAULT_ATTRIBUTES =
%w[_destroy id].freeze
Instance Attribute Summary
#attribute_name, #model, #options
Instance Method Summary
collapse
#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
|
#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
|