PHCDevworks Active Menus Rails 7 engine with helpers to add active class to menus.
- Easily add an active class to menu items based on the current controller.
- Effortlessly add an active class to menu items based on the current action.
- Seamlessly add an active class to menu items based on both the current controller and current action.
gem 'phcdevworks_active_menus'
bundle install
Step 2 - Load Helpers in the Application's Controller
Add the line of code below into your app/controllers/application_controller.rb (application's controller file).
helper PhcdevworksActiveMenus::Engine.helpers
How to Add Active Class Based on Controller Only (Often used for main menu items with sub-menus.)
Add the line of code in between div class tag.
<div class"<%= phc_menu_active_controller("ExampleControllerName") %>">
Add the line of code in between div class tag.
<div class"<%= phc_menu_active_action("ExampleActionName") %>">
How to Add Active Class Based on Controller and Action (Used if you need to get specific.)
Add the line of code in between div class tag.
<div class"<%= phc_menu_active_action_controller("ExampleControllerName", "ExampleActionName") %>">
Status
