Module: ActiveAdmin::ViewHelpers

Defined in:
lib/active_admin/cancan_integration.rb

Instance Method Summary collapse

Instance Method Details

lib/active_admin/view_helpers/auto_link_helper.rb



5
6
7
8
9
10
11
12
13
14
# File 'lib/active_admin/cancan_integration.rb', line 5

def auto_link(resource, link_content = nil)
  content = link_content || display_name(resource)
  if can?(:read, resource) && registration = active_admin_resource_for(resource.class)
    begin
      content = link_to(content, send(registration.route_instance_path, resource))
    rescue
    end
  end
  content
end