module ActiveAdmin::ViewHelpers::AutoLinkHelper
Public Instance Methods
active_admin_resource_for(klass)
click to toggle source
Returns the ActiveAdmin::Resource
instance for a class
# File lib/active_admin/view_helpers/auto_link_helper.rb, line 30 def active_admin_resource_for(klass) return nil unless respond_to?(:active_admin_namespace) active_admin_namespace.resource_for(klass) end
auto_link(resource, link_content = nil)
click to toggle source
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")
# File lib/active_admin/view_helpers/auto_link_helper.rb, line 14 def auto_link(resource, link_content = nil) content = link_content || display_name(resource) if url = auto_url_for(resource) content = link_to(content, url) end content end
auto_url_for(resource)
click to toggle source
Like ‘auto_link`, except that it only returns a URL instead of a full <a> tag
# File lib/active_admin/view_helpers/auto_link_helper.rb, line 23 def auto_url_for(resource) if config = active_admin_resource_for(resource.class) url_for config.route_instance_path resource end end