June 2025
Intermediate to advanced
488 pages
12h 27m
English
Finally, it’s about time to add the index page—the first screen that administrators see when they log in. Let’s make it useful. We’ll have it display the total number of orders in our store. Create the template in the index.html.erb file in the app/views/admin directory. (This template uses the pluralize helper, which in this case generates the order or orders string, depending on the cardinality of its first parameter.)
| | <div class="w-full"> |
| | <h1 class="mx-auto text-lg font-bold">Welcome</h1> |
| | |
| | <p> |
| | It's <%= Time.now %>. |
| | We have <%= pluralize(@total_orders, "order") %>. |
| | </p> |
| | </div> |
The index action sets up the count:
Read now
Unlock full access