Iteration F1: Moving the Cart
Currently, our cart is rendered by the show action in the CartController and the corresponding html.erb template. What weâd like to do is to move that rendering into the sidebar. This means itâll no longer be in its own page. Instead, weâll render it in the layout that displays the overall catalog. And thatâs easy using partial templates.
Partial Templates
Programming languages let you define methods. A method is a chunk of code with a name: invoke the method by the name, and the corresponding chunk of code gets run. And, of course, you can pass parameters to a method, which lets you write a piece of code that can be used in many different circumstances.
You can think of Rails partial templates (partials ...
Get Agile Web Development with Rails 5, 1st Edition now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.