- 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 stub's 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.
First, fork and clone this lab. Before anything, note that when you generate models, controllers, etc, be sure to include this option, so that it skips tests (which we already have): --no-test-framework
We've provided a seeds file so you can have some data to play around with - run rake db:seed
once your migrations and models are complete.
- Refactor the
invoices.html.erb
view to render a collection of partials. - Refactor the
orders.html.erb
view to render a collection of partials.
View Rendering Collections Lab on Learn.co and start learning to code for free.