Controller Inheritance and RESTful routes

Sometimes we might need to implement controller inheritance; to have a DRYer code, a logical way to organize our project using or let it be purely the personal preference. It would be especially helpful for an admin area of a website (which I wanted to implement as well as shown in the example of Justin French)

Admin Lounge Controller:

class Admin::ProductsController

This has been well explained here and it helped me to fix few things which I’ve been struggling to do and also convinced me i was doing something meaningful.

then if we need to use restful routing for these and if you dont know how to create the route similar to admin_products_url or edit_admin_product_url. routes.rb got an example how to get it done. However you can find a better example here.

Controller Inheritance
http://justinfrench.com/index.php?id=122

RESTful routes for Controller Inheritance
http://railstips.org/2007/4/28/namespaces-added-to-routes

Great RESTful RAILS tutorial
http://www.b-simple.de/download/restful_rails_en.pdf

Leave a Reply