Objective: Display specific links in navigation bar for specific routes based on the currently viewed page.
I would like to do something like this in my application.html.haml
if companies_page %li = link_to "Contact Us", contact_path
If there is a better way to do this I am open to suggestions. Thank you!
You might think about using Tabulous which does pretty much exactly that; it allows you to define a set of possible tabs (which you can render as a navigation bar) and also when they should be visible and when they should be active. From the documentation example, part of a tab definition block might be:
visible_when { in_action('any').of_controller('pictures') }
Since that's a block you could easily use more complex logic there, but I imagine that would get very hard to conceptualize very quickly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.