I am trying to render a table of records for a Orders controller in another controller called Dashboard . I've read a lot about doing it with:
<%= render 'orders/index'%>
And it throws the following error:
The current code of my view is:
<div class="container-fluid">
<!-- Primera fila de información -->
<div class="row align-content-center">
<div class="col col-sm-6 border border-dark">
<h3>Primer Espacio</h3>
<!-- <%= render 'orders/index' %> -->
<%=render 'layouts/tables' %>
</div>
<div class="col col-sm-6 border border-dark">
<h3> Segundo Espacio</h3>
<%=render 'layouts/tables' %>
</div>
</div>
I have commented on the erb code to avoid the failure that I am trying to solve. The partial is that it generates by default the Scaffold command in the index.html.erb view p>
<p id="notice"><%= notice %></p>
<h1>Orders</h1>
<table class="table table-sm">
<thead>
<tr>
<th>Fecha pedido</th>
<th>Valorpedido</th>
<th>Provider</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @orders.each do |order| %>
<tr>
<td><%= order.fecha_pedido %></td>
<td><%= order.valorPedido %></td>
<td><%= order.provider %></td>
<td><%= link_to 'Show', order %></td>
<td><%= link_to 'Edit', edit_order_path(order) %></td>
<td><%= link_to 'Destroy', order, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
I have read several methods to do it such as:
<%= render :partial 'orders/order', local:{order:@order}%>
<%= render "orders/index", orders: @orders%>
I think the problem lies in not knowing how to pass the collection of objects
orders
My question is: Can someone help me about how to use the helper correctly?
<%=render%>