Rails as Command Line

It has certainly been said before that the Location Field is the new Command Line. Most users are not going to use it that way, but the fact that it can be used that way is not only neat, but it looks much better and is easier to bookmark.

Some examples. You can see my del.icio.us bookmarks by visiting this URL:

http://del.icio.us/rbrigleb

If you want to see my bookmarks tagged with rubyonrails, you can simply add that to the URL, like so:

http://del.icio.us/rbrigleb/rubyonrails

Or, say you want to see post #288 on this blog. This is the URL:

/notes/288

And actually, this works just as well, and is more friendly to search engines:

/notes/288/google-widgets-for-mac

Simple, no? Many public websites work this way. This makes it dead simple to figure out how to link to, or use, that information within other websites or applications. And that is a good thing! In fact, Ruby on Rails makes it dead simple, almost insisting that your URLs make sense!

But Basecamp (written in Rails) takes this even further. A few months ago time tracking features were added to the system, and this feature has been very motivational. You can essentially conjure up a report of all of the hours you have worked this week. In fact, here is what the URL of this report looks like:

https://needmore.clientsection.com/time/report/75607/20060305/20060311

By gosh that kind of makes sense. The most confusing part is the number 75607, which is presumably my “user ID” in the system. But the rest is simple to decipher. Time is kind of like the name of the data structure we’re interested in within the Basecamp application. Report is the “action,” what we want to do with that data. And the rest of the URL is just my user ID and the starting and ending dates for the report.

Rails makes this kind of thing really easy, with its support for routes, but this is certainly something that can be done in many other languages. The blogging software we use, Textpattern, is written in PHP, but as long as you set it up correctly, you get pretty URLs like the ones shown above.

Raymond Brigleb

Creative Director, dreamer, partner, father, musician, photographer. Has been known to ride the rails. Pulls one heck of a shot.