How to place two columns in a row while using .each method in rails


This Content is from Stack Overflow. Question asked by Fuaad

I want to show two columns of the code in table data tag per row while using ‘.each’ method. But the issue is that the following code displays one column in a row.

  <% @lease.apartment.roommates.each do |roommate| %>
      <td colspan="5">
        <% unless roommate == @lease.second_occupant || roommate == @lease.user %>        
          <% if roommate.current_room.present? %>
              <%= roommate.full_name %> - 
              <% if roommate.current_room.apartment == @lease.apartment%>
                <%= roommate.current_room&.label %> 
              <% end %>
              <br>Email:<%= %><br>Phone:<%= %><br>
              <% if @lease.end_at.present? %>
                Lease End date (if applicable):<%= @lease.end_at %>
              <% end %>
          <% end %>
        <% end %>
  <% end %>


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?