开发者

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 re开发者_高级运维sources ?


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.


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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜