I have created a secondary navigation bar to help users easily navigate through different sections of their account.
DASHBOARD | ACTIVITY | PORTFOLIO | PROJECTS
My goal is to make the current page stand out by making its CSS bold. For example, when a user is on the 'dashboard' page, I want the navigation bar to appear like this:
DASHBOARD | ACTIVITY | PORTFOLIO | PROJECTS
I have tried using code like:
if current_page?(controller: 'users', action: 'edit)
<span class="bold">DASHBOARD</span>
else
DASHBOARD
end
However, this code is not working as expected due to the nested partials I am using to generate the views.
For instance, each user can access their own account information, but since they may have multiple projects, I render a call to a partial located in
views/projects/_list_by_owner.html.erb
and pass in
@projects = Project.where(:owner_id => current_user.id)
from the users_controller#show
.
Because the view is being generated from the users_controller
rather than the projects_controller
, it is not recognizing the correct current_page()
value.
Do you have any suggestions on how to further explore the controller/action nesting or perhaps a more efficient way to dynamically generate the CSS class?