How can I customize the active admin layout?

后端 未结 5 952
梦如初夏
梦如初夏 2021-01-31 09:42

I need to customize the active admin layout, but how can I do it?

5条回答
  •  粉色の甜心
    2021-01-31 10:25

    You can override the active admin page layout by putting the following code in your config/intializers/active_admin.rb file:

    module AdminPageLayoutOverride
      def build_page(*args)
        within super do
          render "shared/your_custom_view_partial"
        end
      end
    end
    
    ActiveAdmin::Views::Pages::Base.send :prepend, AdminPageLayoutOverride
    

    In the above example, I have a custom view file at app/views/shared/_your_custom_view_partial.html.erb location and I am injecting that in all of my active admin pages by the above code.

提交回复
热议问题