Sha256: 5a8162deb1872b5d52f4ebe28dd72b4c1ab7243a4299d79ee882bf6a4d26b255

Contents?: true

Size: 888 Bytes

Versions: 12

Compression:

Stored size: 888 Bytes

Contents

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 == ""
          crumbs << link_to(name, "/" + parts[0..index].join('/'))
        end
        crumbs
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
andrewroth_activeadmin-0.3.4 lib/active_admin/view_helpers/breadcrumb_helper.rb
activeadmin-0.3.4 lib/active_admin/view_helpers/breadcrumb_helper.rb
activeadmin-0.3.3 lib/active_admin/view_helpers/breadcrumb_helper.rb
activeadmin-0.3.2 lib/active_admin/view_helpers/breadcrumb_helper.rb
activeadmin-0.3.1 lib/active_admin/view_helpers/breadcrumb_helper.rb
activeadmin-0.3.0 lib/active_admin/view_helpers/breadcrumb_helper.rb
nsm-activeadmin-0.2.2 lib/active_admin/view_helpers/breadcrumb_helper.rb
saulolso-activeadmin-0.2.2.1 lib/active_admin/view_helpers/breadcrumb_helper.rb
saulolso-activeadmin-0.2.2 lib/active_admin/view_helpers/breadcrumb_helper.rb
activeadmin-0.2.2 lib/active_admin/view_helpers/breadcrumb_helper.rb
activeadmin-0.2.1 lib/active_admin/view_helpers/breadcrumb_helper.rb
activeadmin-0.2.0 lib/active_admin/view_helpers/breadcrumb_helper.rb