class Madmin::Fields::NestedHasMany
Constants
- DEFAULT_ATTRIBUTES
Public Instance Methods
nested_attributes()
click to toggle source
# File lib/madmin/fields/nested_has_many.rb, line 5 def nested_attributes resource.attributes.reject { |i| skipped_fields.include?(i[:name]) } end
resource()
click to toggle source
# File lib/madmin/fields/nested_has_many.rb, line 9 def resource "#{to_model.name}Resource".constantize end
to_model()
click to toggle source
# File lib/madmin/fields/nested_has_many.rb, line 25 def to_model attribute_name.to_s.singularize.classify.constantize end
to_param()
click to toggle source
# File lib/madmin/fields/nested_has_many.rb, line 13 def to_param {"#{attribute_name}_attributes": permitted_fields} end
to_partial_path(name)
click to toggle source
# 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
Private Instance Methods
permitted_fields()
click to toggle source
# File lib/madmin/fields/nested_has_many.rb, line 31 def permitted_fields (resource.permitted_params - skipped_fields + DEFAULT_ATTRIBUTES).uniq end
skipped_fields()
click to toggle source
# File lib/madmin/fields/nested_has_many.rb, line 35 def skipped_fields options[:skip] || [] end