Tuesday 15 January 2013

html - Issues rendering a Bootstrap3 table using a collection -



html - Issues rendering a Bootstrap3 table using a collection -

i've got organization view want render partial in order show users of organization bunch of additional features. have bootstrap panel set up, , within panel want render bootstrap table in order show each user belongs_to organization. can working fine without table css (just separate div elements showing 1 user per line), reason when come create table thing keeps building exclusively new divs each user object. can help?

organization show page html:

<div class="col-md-6"> <ul class="users"> <div class="panel panel-default"> <div class="panel-heading float-left"> <% if current_user.admin? %> <%= link_to "add more users", add_user_path(current_user.organization), class: "btn btn-large btn-success btn-panel" %> <% end %> <h2 class="panel-title">users:</h2> </div> <div class="panel-body panel-height"> <%= render partial: "users_index", collection: @users_index, as: :user %> <br></br> </div> </div> </ul> </div>

the html users_index partial:

<div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>name</th> <th>action</th> </tr> </thead> <tbody> <tr> <td> <%= link_to user.name, user %> </td> <td> <% if current_user.admin? && !current_user?(user) %> <%= link_to "delete", user, method: :delete, data: {confirm: "you sure?" }, class: "btn btn-sm btn-danger pull-right"%> <% end %> </td> </tr> </tbody> </table> </div>

the place users_index defined (my organization controller show function):

def show @organization = organization.find(params[:id]) @users_index = @organization.users end

i tried wrapping in <%= users_index.each |user| %> block, prints out total object of each user above table header generated html below.

what doing wrong here?

the issue comes line:

<%= render partial: "users_index", collection: @users_index, as: :user %>

when render partial user, renders entire content of partial if you'd set in loop. solution take table styling organization show page, , maintain partial wrapped in , classes.

html ruby-on-rails twitter-bootstrap-3

No comments:

Post a Comment