#depot/app/views/carts/_cart.html.erb <h2>Your Cart</h2> <table> <%= render(cart.line_items) %> # как работает? <tr class="total_line"> <td colspan="2">Total</td> <td class="total_cell"><%= number_to_currency(cart.total_price) %></td> </tr> </table> <%= button_to 'Empty cart', cart, method: :delete, data: { confirm: 'Are you sure?' } %> #depot/app/views/line_items/_line_item.html.erb <tr> <td><%= line_item.quantity %>×</td> <td><%= line_item.product.title %></td> <td class="item_price"><%= number_to_currency(line_item.total_price) %></td> </tr>
_cart.html.erb
is called from layout: <%= render @cart %>
What happens in this code, how do partial templates work?