Creating the Catalog Listing
Explore how to build a catalog listing page by generating a Store controller in Rails, setting the root URL, and retrieving products from the database. Learn to order products alphabetically, use view templates, helpers like image_tag and sanitize, and add styling for a customer-facing store page.
We'll cover the following...
We’ve already created the products controller, which will be used by the seller to administer the Depot application. Now it’s time to create a second controller to interact with the paying customers. Let’s call it “Store:”
depot> bin/rails generate controller Store index
A live terminal
Try the above command in the terminal provided below
In the previous chapter, we used the generate utility to create a controller and associated scaffolding to administer the products. Here we’ve asked it to create the StoreController class in the store_controller.rb file, which contains a single action method, index().
Everything is already set up for this action to be accessed via running the ...