Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a link back to the application in ActiveAdmin?

I need to add a few links to certain pages of the application in the ActiveAdmin pages. I can do this using sidebars, but I'll have to repeat the code for each of my resources. Is there anyway of adding custom links to the header ? Or define a sidebar that will appear for all resources ?

like image 918
karthik c Avatar asked Aug 26 '11 03:08

karthik c


3 Answers

I also wouldn't want to overlook setting config.site_title_link in initializers/active_admin.rb.

I'm pretty sure it takes a symbol representing the name of a route from your application, for example:

config.site_title_link = :root

would link the site title to your application's root_path.

like image 130
Michael Hellein Avatar answered Nov 03 '22 14:11

Michael Hellein


Thanks @phoet ! Implemented it by overriding the HeaderRenderer instead:

  module ActiveAdmin
    module Views
      class HeaderRenderer
        def to_html
          title + global_navigation + application_link + utility_navigation
        end

        def application_link
          link_to('Back to Application', root_url)
        end
      end
    end
  end
like image 11
karthik c Avatar answered Nov 03 '22 13:11

karthik c


i think there is no build-in way to do it, but you can override the render-logic in the TabsRenderer (2.2) / TabbedNavigation (3.0):

  def render_menu(menu)
    content_tag :ul, :id => @options[:id] do
      menu.items.collect do |item|
        render_item(item)
      end.join.<<('your_custom_stuff').html_safe
    end
  end
like image 2
phoet Avatar answered Nov 03 '22 12:11

phoet