I create a class to override the default helper.
Use case:
# ModelsclassCompanyincludeMongoid::Documentembeds_many:catalogs,{class_name: 'Company::Catalog'}endclassCompany::CatalogincludeMongoid::Documentembedded_in:companybreadcrumbdomongoid_breadcrumb_linksendend# ActiveAdminActiveAdmin.registerCompanydoendActiveAdmin.registerCompany::Catalog,as: 'Catalog'dobelongs_to:companyendmoduleActiveAdmin::ViewHelpers::BreadcrumbHelper# Returns an array of links to use in a breadcrumbdefmongoid_breadcrumb_links(path=request.path)# remove leading "/" and split up the URL# and remove last since it's used as the page titleparts=path.split('/').select(&:present?)[0..-2]resources=[]parts.each_with_index.mapdo |part,index|
# 1. try using `display_name` if we can locate a DB object# 2. try using the model name translation# 3. default to calling `titlecase` on the URL fragmentifpart =~ /\A(\d+|[a-f0-9]{24}|(?:[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}))\z/ && parts[index - 1]parent=active_admin_config.belongs_to_config.try:targetconfig=parent && parent.resource_name.route_key == parts[index - 1] ? parent : active_admin_configparent_resource=resources.last### main difference from https://github.com/activeadmin/activeadmin/blob/646bf004782e4eae912ff8821f36db691f49fcfb/lib/active_admin/view_helpers/breadcrumb_helper.rbresources << ifparent_resourcecollection=parent_resource.send(config.resource_name.collection)collection.findpartelseconfig.find_resourcepartend##name=display_nameresources.lastendname ||= I18n.t"activerecord.models.#{part.singularize}",{count: ::ActiveAdmin::Helpers::I18n::PLURAL_MANY_COUNT,default: part.titlecase}# Don't create a link if the resource's show action is disabledif !config || config.defined_actions.include?(:show)link_toname,'/' + parts[0..index].join('/')elsenameendendendendTIP: Disable company filter in ActiveAdmin.register Company::Catalog because Formtastic doen't work very well with embedded reference.
I create a class to override the default helper.
Use case: