Jon Aquino's Mental Garden

Engineering beautiful software jon aquino labs | personal blog

Saturday, March 11, 2006

What Makes Rails Great - Its Directory Structure

The greatest thing about Ruby on Rails is not its code generators. Nor is it its automatic database-to-object mapping (though that is pretty sweet). It's the directory structure.

A Rails app has three main directories: models, views, controllers (also the very important test directory). Here's the key: the controllers set up the variables for the views. So the PhotoController's "new" method sets up the variables for the new.rhtml view. The PhotoController's "edit" method sets up the variables for the edit.rhtml view. I love the consistent naming.

And notice how every "thing" has the same set of actions. Whether a comment, event, person, photo, or topic, they all pretty much do the following: edit, list, new, view. Again, wonderful consistency.

Over the past 6 months I've written a variety of web apps -- hiking reviews, a sports poll, a craigslist clone, find-a-programmer, a social network. Not one using Ruby*. Not one using a framework (gasp). All of them using the extremely clever directory structure that I learned from Ruby on Rails.

Try it with another language!

* They were written in PHP
** The files in the above example are from Group.


Post a Comment

<< Home