I have been using Active admin gem and want to remove the breadcrumbs from Admin dashboard. To achieve this I referred this blog to customize TitleBar.
I did following steps:
MyTitleBar and copied content of TitleBar class from active_admin/views/title_bar.rb.build_breadcrumb line in method build_titlebar_left.build_breadcrumb.Updated active admin config as:
config.view_factory.title_bar = MyTitleBar
This works fine.
My Questions:
breadcrumbs model-wise?While that solution may work, it's certainly less than ideal. I noticed looking at the ActiveAdmin gem that their is a configuration option for breadcrumb:
ActiveAdmin.register Post do
breadcrumb do
[
link_to('my piece', '/my/link/to/piece')
]
end
end
It looks like it takes a code block, which is returned to a links variable. Looking at TitleBar::build_breadcrumb, if this configuration option isn't defined, it just sets links to the result of breadcrumb_links(). Finally, if some type of links array is there, it formats it for printing. Otherwise, the method returns nothing.
So to solve your problem, try writing a code block that returns nil or an empty. I haven't tested this, but something along the lines of the code block below. The idea is that if you feed the variable nil, it should not pass the links.present? test and should return immediately, not building the undesired breadcrumb HTML. Alternatively an empty array should fit the type it expects, but without any items nothing should be displayed. I'd need to test locally to see which works better on the frontend.
/config/initializers/active_admin.rb:
# Return a Proc that simply returns an empty array
config.breadcrumb = Proc.new{ [] }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With