Improving the Dashboard
In Chapter 6 , you built a rudimentary administrative dashboard that allows the client to manage
categories, products, and other details on the site. In this chapter, you ’ re add some more advanced
functionality to the dashboard and also address some issues that have been lingering in the project.
For example, what happens when you delete a category or product? What do you do about colors
and sizes?
By the end of the chapter, you should have a fully functioning admin panel, with every item from
the current sprint backlog addressed.
Batch Mode Operations
One of the more prominent items on the sprint backlog is allowing Claudia to assign categories
and groupings to her products in batch mode. Access to such a tool would save her a lot of time, as
the only way she can update these settings is by editing one product at a time.
The easiest way to add a batch mode process to the products home view is to make it into a form.
You want to end up with one checkbox per product listing (using the product ID as the value of
each checkbox), a dropdown list for category selection, and a text field that accepts a grouping
string.
Once you have all that in the view, you ’ ll create a specialized function in the products controller
and a corresponding model function that will handle the updates for you. Then, all you have to do
is post the form to that specialized controller function, and you have a batch mode operator!
In the following code, the form elements have been placed inside admin_products_home view.
The bold lines represent new code.