In this screencast, admin namespaced products controller is created. This gives products_controller in the admin directory.
The public products_controller has only index and show and the other actions are not needed so we delete them. The admin products controller is capable of all the CRUD operations. So we copy them over to the admin controller. The urls needs to be changed because when we access them as an admin the url on the browser will be:
Since we have admin in the url the url helper methods will be different than the public url methods. You can find out the name of the URL methods by doing rake routes in your rails project home directory. Here is the process:
1. Let's say you want to find out the name of the URL helper method to route to update action in admin's products controller.
2. Look at the output of rake routes and find the controller with value admin/products and action with value show. The first column will give you the name of the URL helper you should use in the admin/products_controller and the views under admin/views/ directory.
3. The :id in the /admin/products/:id is a variable that is available in the params hash. You can access it's value in your controller by doing params[:id]. Similarly if you find anything in the second column that is prefixed by : , it means that it is a variable and you can extract it's value in the controller from the params hash.