Module: Ddr::Models::HasChildren

Included in:
Collection, Item
Defined in:
lib/ddr/models/has_children.rb

Instance Method Summary collapse

Instance Method Details

#first_childObject



5
6
7
8
9
10
11
12
13
# File 'lib/ddr/models/has_children.rb', line 5

def first_child
  child_class = self.class.reflect_on_association(:children).klass
  if has_struct_metadata?
    child_class.find(structure.default_struct_map_ids.first)
  else
    solr_field = child_class.reflect_on_association(:parent).solr_key
    child_class.where(solr_field => id).order("#{Ddr::Index::Fields::LOCAL_ID} ASC").first
  end
end