- Use the
collection
keyword with partials - Pass a collection to the render method
- Handle empty collections
Let's go back to our store domain. We had an admin portion of the site where admins could check on their orders and invoices. We've changed it slightly so that, rather than static pages with stubs for orders, we've seeded the database with actual order data. Let's refactor the admin portion of the store to use partials and render collections.
We've provided a seed file so you can have some data to play around with –– run rake db:seed
to seed the database.
- Refactor the
invoices/index.html.erb
view to render a collection of partials with_invoice.html.erb
. - Refactor the
orders/index.html.erb
view to render a collection of partials with_order.html.erb
.