Sha256: 065cda0a1daba352523837bdc74fdf7c774b1051191731e8c5d71b1088dd5fec

Contents?: true

Size: 344 Bytes

Versions: 5

Compression:

Stored size: 344 Bytes

Contents

module Ddr
  module Models
    module HasChildren

      def first_child
        child_class = self.class.reflect_on_association(:children).klass
        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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ddr-models-3.0.0.beta.1 lib/ddr/models/has_children.rb
ddr-models-3.0.0.alpha.4 lib/ddr/models/has_children.rb
ddr-models-3.0.0.alpha.3 lib/ddr/models/has_children.rb
ddr-models-3.0.0.alpha.2 lib/ddr/models/has_children.rb
ddr-models-3.0.0.alpha.1 lib/ddr/models/has_children.rb