You need quite a few changes in your code:
Change
<%= e.requisitions.map do |e| %> <%= e.name %> <% end %>
To
<% e.requisitions.each do |requisition| %> <tr> <td><%= requisition.name %></td> <td><%= requisition.particular %></td> ... </tr> <% end %>
Removed
=
and changed block variable torequisition
.=
was causing<ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_Requisition:0x3cd32c0>
part in your rendered output. You should not be renderinge.requisitions
. You also need to surround the data with appropriate<tr>
and<td>
elements.As per the chat session, even after fixing point 1, your code was not behaving correctly. Every time you click on
<%= e.requisitions.count %> Assets
button assets of first employee were rendered even when you click on any other employees assets button. This happens because you are using the same idmyModal
for all the created divs created for modal functionality.So, when you click on the asset button, DOM would look for the first element with id
myModal
and return it. Hence, you get the details of 1stemp
every time. In order to avoid this, you need to make unique id's for all your modal div's.Replace
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
With
<div class="modal fade" id="myModal<%= e.id %>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
This will create
id
of modaldiv
element foremp with id 1 as : myModal1, emp with id 2 as : myModal2
For change #2 to work correctly, you need to update the asset link as below:
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal<%= e.id %>"> <%= e.requisitions.count %> Assets </button>
Due to
data-target="#myModal<%= e.id %>"
, appropriate modal would be selected. Foremp with id 1 as : myModal1 would be shown, emp with id 2 as : myModal2 would be shown