How to Tell if a Rails Example is Up-to-Date

Do you check the “sell-by” date on a carton of milk before you buy it? Unfortunately, there is no date on a Rails app to indicate if it has been written with recent best practices in mind. So check for a sour smell. Here are some indicators I look for.

First, is it RESTful? More than anything else, a RESTful architecture makes an app easier to understand, customize, and maintain. To determine if the developer used a RESTful architecture, look at the code for the controllers. If there are any methods other than index, show, new, create, edit, update, and destroy the developer has strayed from RESTful purity.

Second, has the app been written or updated for use with Rails 2.0? If you’re beginning a project, you’ll want to start with Rails 2.0. Some things are done a little differently in Rails 2.0. If you’re using an example app as a guide, make sure it’s a good example of how to do things with Rails 2.0.

To determine if the developer wrote for Rails 2.0:

In the config/environment.rb file, look for

Look for the folder config/initializers. Before Rails 2.0, the config/environment.rb file was cluttered with bits of initialization code. With Rails 2.0, we are encouraged to move initialization code to separate files in the config/initializers folder.

Take a look at the files in the Views folder. With Rails 2.0, the recommended practice is to use the file extension .html.rb. You don’t have to do that, but it is now recommended.

Finally, here is a script that will check a rails app to determine if it is compatible with Rails 2.0:


Comments are closed.

%d bloggers like this: