Bootstrap navigation tabs with rails subpages
<p>I'm attempting to style a rails app with bootstrap <a href="http://getbootstrap.com/components/#nav" rel="nofollow">navigation tabs.</a> My App is such that I have not only pages but subpages as well.  Tabs represent superpages (so to speak).  See below: </p>

<pre><code>&lt;ul class="nav nav-tabs"&gt;
    &lt;li class="tab"&gt;&lt;%= link_to "Contacts", edit_entities_path(@company) %&gt;&lt;/li&gt;
    &lt;% for stock in @company.stocks.each %&gt;
        &lt;% if stock.id %&gt;
            &lt;li class="tab"&gt;&lt;%= link_to "#{stock.security_series} #{stock.security_class} Stock", stock_stockholders_path(stock) %&gt;&lt;/li&gt;
        &lt;% end %&gt;
    &lt;% end %&gt;
    &lt;% for option in @company.options.each %&gt;
        &lt;% if option.id %&gt;
            &lt;li class="tab"&gt;&lt;%= link_to "#{option.security_series} #{option.security_class} Options", option_optionees_path(option) %&gt;&lt;/li&gt;
        &lt;% end %&gt;
    &lt;% end %&gt;
    &lt;% for warrant in @company.warrants.each %&gt;
        &lt;% if warrant.id %&gt;
            &lt;li class="tab"&gt;&lt;%= link_to "#{warrant.security_series} #{warrant.security_class} Warrant", warrant_warrantees_path(warrant) %&gt;&lt;/li&gt;
        &lt;% end %&gt;
    &lt;% end %&gt;
    &lt;% for note in @company.convertible_notes.each %&gt;
        &lt;% if note.id %&gt;
            &lt;li class="tab"&gt;&lt;%= link_to "#{note.security_series} #{note.security_class} Note", convertible_note_convertible_notees_path(note) %&gt;&lt;/li&gt;
        &lt;% end %&gt;
    &lt;% end %&gt;
&lt;/ul&gt;
</code></pre>

<p><em>Tabs denote any number of stocks, convertible_notes, options, and warrants</em></p>

<pre><code>resources :stocks do
    resources :stockholders
end
resources :convertible_notes do
    resources :convertible_notees
end


resources :options do
    resources :optionees
end

resources :warrants do
    resources :warrantees
end
</code></pre>

<p>For more context a <code>Company</code> <code>has_many :stocks :convertible_notes :options :warrants</code></p>

<p><strong>What I'm after:</strong> I would like to apply the active class if I am on a given page OR if I'm on its sub-page.  So, I not only want the stock with ID 1's tab to be <code>.active</code> if I'm on it, but also if I'm on the stockholder subpage.</p>

<p>What might be the best way to accomplish this?  Thanks in advance.</p>