I need to access all values from Database according to id
but i am getting the following output.
Output:
all details are #<PaymentVendor:0x1ee5860>
all details are #<PaymentVendor:0x1f02798>
I am explaining my code below.
@rest_ids=[21,22,23]
@rest_ids.each do |ids|
@pdf_vendor_details = PaymentVendor.where(:id => ids )
puts "all details are #{@pdf_vendor_details}"
end
From the above code i have some array of ids(i.e- @rest_ids
).Here my requirement is when the loop will execute as per id the record will fetch and store in the variable @pdf_vendor_details
in array.If I wanted to display some value in table then i will be able to do that like below.
table.html.erb:
<table>
<tr>
<td>ID</td>
<td>Receipt No</td>
<td>Amount</td>
</tr>
<% @pdf_vendor_details.each do |details| %>
<tr>
<td><%= details.id %></td>
<td><%= details.Receipt_No %></td>
<td><%= details.Amount %></td>
</tr>
<% end %>
</table>
But doing this way i can not get any value and unable to display data in table.Please help me to access the data from DB
which will store in array to display in table.