Module: IronAdmin::Concerns::Nestable::NestedReader
- Defined in:
- lib/iron_admin/concerns/nestable.rb
Overview
Reader and resolver for nested associations.
Instance Method Summary collapse
Instance Method Details
#nested_associations ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/iron_admin/concerns/nestable.rb', line 35 def nested_associations defined_associations.select { |_, v| v[:nested] }.map do |assoc_name, config| reflection = adapter.association(assoc_name) raise ArgumentError, "Unknown association #{assoc_name} for #{model.name}" unless reflection NestedAttributesValidator.validate!(model, assoc_name) fields = resolve_nested_fields(config, reflection.klass, reflection.foreign_key) NestedAssociation.new( name: assoc_name, kind: config[:kind], reflection: reflection, fields: fields, allow_destroy: config.fetch(:allow_destroy, true), position_field: config[:position_field] ) end end |