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

前端 未结 3 1267
陌清茗
陌清茗 2021-01-12 08:35

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 resour

相关标签:
3条回答
  • 2021-01-12 09:13

    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
    
    0 讨论(0)
  • 2021-01-12 09:29

    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.

    0 讨论(0)
  • 2021-01-12 09:30

    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 讨论(0)
提交回复
热议问题