Easy Restful Rails Screencast

2008 January 25, 20:26 h

Update 2013: This video is very obsolete. Later, Inherited Resources superseded it, but most programmers prefer not to go so deep in metaprogramming “magic” and keep the controllers less implicit for maintenance purposes.

Update 28/01: It seems like James Golick and I were in sync here. :-) We both did screencasts at the same time. He just recorded one for his other great plugin, attribute_fu, and I did it for resource_controller. He posted both at his blog:http://jamesgolick.com/2008/1/28/look-out-ryan-bates-there-s-a-new-screencast-in-town. Check it out.

This is my second try at making a useful screencast. I think my last one, “The First Rails 2.0 Screencast” (http://www.akitaonrails.com/2007/12/10/the-first-rails-2-0-screencast-english), was reasonably good but far from good enough. I thank everybody who has seen it and helped make it one of the most successful pieces I’ve ever made.

I’ve been wanting to explore the Restful Rails concepts in a screencast. First and foremost, I highly recommend Geoffrey Grosenbach’s Peepcode screencast as one of the most comprehensive and easy to understand. My screencast is not nearly at the same level of quality or depth, but I didn’t want to reinvent the wheel.

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.

tags: obsolete rails screencast english

Comments

comentários deste blog disponibilizados por Disqus