Rails App Template

I start a lot of projects. More than I’d like to admit. I finish and deploy very few, but I like cranking out the first iteration of an app in a weekend. Sometimes I do it just to learn some new feature, or try out an architecture idea. I don’t like to do this in the context of whatever existing app I’m working on, because I don’t want any baggage of whatever I was thinking last week. Last week is too long ago.

I’ve had this technique validated by my former boss Ward Cunningham. He (famously) worked with Kent Beck at Tektronix and they were research partners. During this time, they came up with lots of really great ideas, design patterns, and methodologies. And the technique they used for exploration went something like this (paraphrased from Ward):

Kent and I would get to work in the morning, and we’d just start writing code. If it went well, we might right code all morning and maybe all day. If it went really well, we’d work on the same project all week and get something great out. Usually these ideas then got turned over to other teams to keep working on.

But usually, these ideas didn’t work out very well. So we’d stop at lunch, throw it all away, and work on whatever we were supposed to be working on.

The next morning, we would both show up and Kent would usually say “I have an idea on that thing we were working on yesterday” and off we’d go.

Great things came out of this, TDD, some notable design patterns, and really XP.

The thing that holds me back from doing this more, is that frankly, it’s a pain in the ass to get all the basics in a rails app installed. Just to do anything, I usually like to have Rspec, rspec-rails, cucumber, authlogic, jquery, 960gs, and a handful of other plugins and libraries installed. They all need to be configured, databases need to be set up, etc.

Worst of all, most things need authentication, you know, so that you can actually have users. That means you need sign up, login, activation, password resets, emails, the list goes on.

Where am I going with this? Well, the ability to generate rails apps via custom templates was added in Rails 2.2. So I took it upon myself to stop shaving small yaks every time I wanted to hack on a new project and shave a big one. I present, the science department rails template.

rails my_app -d postgresql -m http://github.com/BJClark/rails-templates/blob/d8889e1c771847f75641503e478c130e959e1686/scidept.rb

Run this little command, answer 3 questions, change 1 line of code, and run

rake spec && rake features

You now have a fully implemented and tested, rails/rspec/cucumber/authlogic/resource_controller/lesscss/jquery/960gs app, with signup, login, and password resets, checked into git and ready to hack.

Hack, fork, and profit!

Show Comments