I think Rails 3 is awesome and kudos to the core team and hoards to contributors that made it happen.  However, I am sad that it has gotten more verbose to create a Rails app from scratch.  I know not everyone likes scaffold and not everyone uses rspec, but this is a common use case, and it gets a little worse if you use cucumber, like we do in the workshops.  In fact any test framework gem dependency is going to have this kind of a problem.  I teach novices periodically and frequently use scaffold in my own work for prototyping and for experimenting with new gems.  The fact that I have to open up an editor and modify my gem file creates a context switch, plus I’ve got a couple of extra commands to type.  There used to be 6 commands, now there are 8 to get the most basic webapp running.  I think we can do better…

———– old steps ————–
$ rails myapp
$ cd myapp
$ script/generate rspec
$ script/generate scaffold note title:string content:text
$ rake db:migrate
$ script/server

———– new steps ————–
$ rails new myapp
$ cd myapp
$ vi Gemfile

group :development, :test do
gem ‘sqlite3-ruby’, :require => ‘sqlite3’
gem “rspec-rails”, “>= 2.0.0.beta.22”
gem “webrat”      # currently generated view specs require this
end

$ bundle install
$ rails generate rspec:install
$ rails generate scaffold note title:string content:text
$ rake db:migrate
$ rails server

I wonder if there should be something like the git config command.  Such as:

rails gem rspec

Ideally it would run the generator if there is one and edit the Gemfile.  Ideally it would allow the specification of multiple gems with an optional parameter to call bundle install at the end:

rails gem rspec webrat –install

This would allow all of the goodness of bundler without the cognitive overhead (till you need it).

2 thoughts on “rails 3: can we get back to 6 steps?

  1. Hmm. Wouldn’t using a template solve this problem for you?

    $ rails new myapp -m my_rspec_template
    $ cd myapp
    $ bundle install
    $ rails generate rspec:install
    $ rails generate scaffold note title:string content:text
    $ rake db:migrate
    $ rails server

    It’s not *quite* as useful for introductory courses as the old way, since there’s the magical (to novices) template stuff in there, but it would let you focus more on the important stuff up front.

  2. This is what we do for the workshops:
    rails suggestotron -m http://gist.github.com/316450.txt

    That’s ok for a one day class, but I wouldn’t want to rely on a template for longer class. For my personal use, templates are fine, but I find that I’m updating gems and rails versions and switching between projects often enough that it isn’t worth it to me to maintain a set of templates. I did think about whether there should be a short URL services for templates, but then I thought… why not just make it even simpler and still have a command that corresponds to each cognitive steps. The biggest problem with a template is that it hides what is inside it. With the “rails gem” idea it is kind of self-documenting.

What do you think?