I have a dynamic submenu that is rendered according to which page the user is on. I placed the following code in a _sub_menu.html.erb partial:
<a href="/dashboard/index" class="current">Index</a>
<a href="/dashboard/account">Account</a>
<a href="/dashboard/payments">Payments</a>`
From my my main view, I call <%= render 'sub_menu' %>
, which works.
However, I want to change the class="current" part according to which page the user is on. I was hoping to do this from the render by passing in a local parameter and rendering according to that, but it seems hacky:
<%= render 'sub_menu' , :locals => {:active_item => 'payments'} %>
Plus the logic becomes really ugly. Is there a better way of doing this?