开发者

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

开发者 https://www.devze.com 2023-03-31 10:05 出处:网络
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 add

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

精彩评论

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

关注公众号