修改活动管理模块以隐藏痕迹导航



链接belongs_to上的活动管理员存在一些问题。 除其他外,它会导致面包屑有时显示错误的链接。

我希望找到一种方法,通过在初始值设定项中修改活动的管理员面包屑帮助程序,简单地隐藏某些(但不是全部)页面上的痕迹导航。 F 例如:

module ActiveAdmin
 module ViewHelpers
  module BreadcrumbHelper

    def breadcrumb_links(path = request.path)
      if @hidebread 
        false
      else
        parts = path[1..-1].split('/') # remove leading "/" and split up the URL
        parts.pop                      # remove last since it's used as the page title
        parts.each_with_index.map do |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 fragment
          if part =~ /A(d+|[a-f0-9]{24})z/ && parts[index-1]
            parent = active_admin_config.belongs_to_config.try :target
            config = parent && parent.resource_name.route_key == parts[index-1] ? parent : active_admin_config
            name   = display_name config.find_resource part
          end
          name ||= I18n.t "activerecord.models.#{part.singularize}", :count => ActiveAdmin::Helpers::I18n::PLURAL_MANY_COUNT, :default => part.titlecase
          link_to name, '/' + parts[0..index].join('/')
        end
      end
    end
  end
 end
end

这给出了错误"未初始化的常量ActiveAdmin::Helpers::I18n"。 可悲的是,了解如何解决这个问题有点超出了我的 Rails 技能。 有没有办法解决这个问题,或者有没有办法在模块上调用类似"super"的东西,以便我可以做一些类似于

    def breadcrumb_links(path = request.path)
      if @hidebread 
        false
      else
        super
      end
    end

这是大约 2.5 周前刚刚添加到最新版本的 ActiveAdmin 中。

# Gemfile
gem 'activeadmin', github: 'gregbell/active_admin'
# app/admin/my_model.rb
ActiveAdmin.register MyModel do
  config.breadcrumb = false
end

最新更新