Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:03:30+00:00 2026-06-02T15:03:30+00:00

I am using Bootstrap in my rails app and in particular, I would like

  • 0

I am using Bootstrap in my rails app and in particular, I would like to extend Bootstrap’s tabbable functionality in the following sense:

Each user of my site can have multiple profiles, namely model User has_many profiles, and I would like to display these profiles across tabs in their user/show page. Each profile has a name attribute which I want to display on the tab itself.

I was previously rendering these profiles using the typical conventions:

On user/show page:

<%= render 'shared/prof %>

shared/_prof:

<% if @prof_items.any? %>
  <ol class="profiles">
    <%= render partial: 'shared/prof_item', collection: @prof_items %>
  </ol>
  <%= will_paginate @prof_items %>
<% end %>

shared/_prof_items

<li id="<%= prof_item.id %>">
...content...
</li>

users_controller:

...
def show
  @user = User.find(params[:id])
  @profiles = @user.profiles.paginate(page: params[:page])
  @profile = @user.profiles.build
  @prof_items = @user.prof.paginate(page: params[:page])
  ...
end
...

So essentially I would like the outputted html to be like this:

<div class="tabbable" style="margin-bottom: 5px;">
 <ul class="nav nav-tabs" id="tabHeaders">
  <li class="active">
   <a href="#tab_<%=prof_item.id%>" data-toggle="tab">Name of first profile</a>
  </li>
  <li>
   <a href="#tab_<%=prof_item.id%>" data-toggle="tab">Name of second profile</a>
  </li>
  #and so on for each prof_item
 </ul>
<div class="tab-content" id="tabContent">
 <div class="tab-pane active id="<%=prof_item.id%>">
  #render first profile item
 </div>
 <div class="tab-pane" id="<%=prof_item.id%>">
  #render second profile item
 </div>
</div>

However I’m not sure what code I need in user/show.html.erb, what code I need in shared/_prof_item.html.erb, and what code I need in shared/_prof.html.erb.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:03:31+00:00Added an answer on June 2, 2026 at 3:03 pm

    You can simplify your code by using rails facility to render collections:

    <%= render partial: 'shared/prof_item', collection: @prof_items) %>
    <%= render partial: 'shared/profile', collection: @profiles) %>
    

    shared/_profile.html.erb: # use local variable profile

         <div class="tab-pane active" id="<%=profile.id%>">
         #render first profile
         </div> 
    

    shared/_prof_item.html.erb # use local variable prof_item

        <li>
        <a href="#tab_<%=prof_item.id%>" data-toggle="tab">Name of second profile item</a>
        </li> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

another newbie-question regarding rails and bootstrap. I am using something like this: <div class=tabbable
I would like to use the following media query in my rails app. @media
Im setting up a rails app using the bootstrap-sass version for rails. In following
I am using Twitter Bootstrap in my rails app. My navbar looks perfect in
I'm using Twitter Bootstrap for a Rails 3.2.3 project and I'm importing each stylesheet
Going nuts here. I'm developing a rails app, and I'm using the twitter-bootstrap-rails gem
I am using bootstrap-sass in my rails app. I want to override a bootstrap-sass
In my rails app, I'm using Twitter bootstrap. Before, everything was working fine, but
I am working on a really simple app that is styled using twitter-bootstrap-rails. One
I have a Rails app with Twitter Bootstrap installed. Bootstrap encapsulates each navigation bar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.