<commit_before>module ActiveAdmin
  module ViewHelpers
    module BreadcrumbHelper

      # Returns an array of links to use in a breadcrumb
      def breadcrumb_links(path = nil)
        path ||= request.fullpath
        parts = path.gsub(/^\//, '').split('/')
        parts.pop unless %w{ create update }.include?(params[:action])
        crumbs = []
        parts.each_with_index do |part, index|
          name = ""
          if part =~ /^\d/ && parent = parts[index - 1]
            begin
              parent_class = parent.singularize.camelcase.constantize
              obj = parent_class.find(part.to_i)
              name = obj.display_name if obj.respond_to?(:display_name)
            rescue
            end
          end
          
          name = part.titlecase if name == ""
          begin
            crumbs << link_to( I18n.translate!("activerecord.models.#{part.singularize}", :count => 1.1), "/" + parts[0..index].join('/'))
          rescue I18n::MissingTranslationData
            crumbs << link_to( name, "/" + parts[0..index].join('/'))
          end
        end
        crumbs
      end

    end
  end
end<commit_msg>fix breadcrumb for mongoid<commit_after>module ActiveAdmin
  module ViewHelpers
    module BreadcrumbHelper

      # Returns an array of links to use in a breadcrumb
      def breadcrumb_links(path = nil)
        path ||= request.fullpath
        parts = path.gsub(/^\//, '').split('/')
        parts.pop unless %w{ create update }.include?(params[:action])
        crumbs = []
        parts.each_with_index do |part, index|
          name = ""
          if part =~ /^\d|^[a-f0-9]{24}$/ && parent = parts[index - 1]
            begin
              parent_class = parent.singularize.camelcase.constantize
              obj = parent_class.find(part[/^[a-f0-9]{24}$/] ? part : part.to_i)
              name = obj.display_name if obj.respond_to?(:display_name)
            rescue
            end
          end
          
          name = part.titlecase if name == ""
          begin
            crumbs << link_to( I18n.translate!("activerecord.models.#{part.singularize}", :count => 1.1), "/" + parts[0..index].join('/'))
          rescue I18n::MissingTranslationData
            crumbs << link_to( name, "/" + parts[0..index].join('/'))
          end
        end
        crumbs
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.13000852514919012, 'fraction_numerical': 0.011082693947144074, 'mean_word_length': 1.8074162679425838, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6534735', 'n_tokens_mistral': 707, 'n_tokens_neox': 700, 'n_words': 160}