Sha256: ed54e6c4de83e4d8e68bdf1087562954f800e75b76333b1fb50f2b9554138508
Contents?: true
Size: 1.06 KB
Versions: 12
Compression:
Stored size: 1.06 KB
Contents
module ActiveAdmin module ViewHelpers module AutoLinkHelper # Automatically links objects to their resource controllers. If # the resource has not been registered, a string representation of # the object is returned. # # The default content in the link is returned from ActiveAdmin::ViewHelpers::DisplayHelper#display_name # # You can pass in the content to display # eg: auto_link(@post, "My Link Content") # def auto_link(resource, link_content = nil) content = link_content || display_name(resource) if (registration = active_admin_resource_for(resource.class)) begin content = link_to(content, registration.route_instance_path(resource)) rescue # ignored end end content end # Returns the ActiveAdmin::Resource instance for a class def active_admin_resource_for(klass) return nil unless respond_to?(:active_admin_namespace) active_admin_namespace.resource_for(klass) end end end end
Version data entries
12 entries across 12 versions & 3 rubygems