Explanation
So, the idea came when I saw James Golick’s excelent “resource_controller” plugin:https://jamesgolick.com/resource_controller plugin. It does what I always thought should be part of Rails itself: it makes Restful Controller as easy to use and understand as ActiveRecord originally does for Models and the database.
This screencast is a quick rendition of this plugin and how to use it to leverage the power of Restful Controller in your applications. This is one of those great ideas that – who knows – could find its place in the Rails Core one day, the same way Sexy Migrations did.
The concept is that now that we treat a controller’s action in a standardized way (through the abstraction of HTTP verbs), it could perfectly be refactored away from day-to-day development. So, instead of scaffolding creating a bunch of repeated code in every controller, why not have a bare-bone controller, totally empty, to start with?
Another clever idea was to create dynamic helpers for named routes in the views. That way, you can move your views around and even reuse them in different sections without ever copying & pasting several different named routes between them. This is particularly useful for polymorphic controllers and namespaced routes, as I have shown in this video.
At the very end of the video, I provide a quick summary of what Restful Rails provides in terms of route organization, which could be helpful to some.
I hope you enjoy it!
Disclaimer: This video is around 50 min long. I first recorded it live in English, and I tried to do voice over it in Portuguese. But it was so difficult that I decided to record another version in Portuguese again. This second video had a different concept, and I explained Restful Rails in more detail because the Brazilian audience can’t understand English well enough to learn through Peepcode. So, if you can understand Portuguese, you will also want to check it out.