简体   繁体   中英

How to have add a vertical navigation or side bar, in a view other than application.html.erb and make it available to certain views, Ruby on Rails?

My tabs view look like this (Remember this is not part of application.html.erb, since I need the tabs to be available only to certain specific pages):

<div>
<div class="tabbable tabs-left">
<ul class="nav nav-tabs nav-stacked">
    <li class="active">
        <a href="settings_mail">Mail Settings</a>
    </li>
    <li>
        <a href="settings_text">Text Settings</a>
    </li>
</ul>   
</div>

But, on clicking on any of the above tabs, the vertical tabs disappear and goes to the respective views. I would like to retain the tabs in each page it navigates to, any pointers are welcome.

How about using something like

layout "other_layout"

in the relevant controllers? Like explained in http://guides.rubyonrails.org/layouts_and_rendering.html , "2.2.12.1 Specifying Layouts for Controllers"

You can use yield :tag in your layout and use

content_for :tag do
  "your tabs"
end

in your views where you want tabs and don't put content_for method in view where you don't want these tabs.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM