-What's extglob used here for? I don't see any regexes.
-What are libffi-dev and libyaml-dev for? I assume some common gems depend on them. If so, which? (I'm just getting into Rails.)
-Git in the Maverick repos is old (1.7.1, which was released in April). Installing it from source is probably a better idea.
-You should probably use RVM to install Ruby, since its 1.9.2-head target won't require you to keep updating your script with 1.9.2's patchlevel.
-In my rails3.sh (which I should really publish), I didn't need to `gem install bundler` in order for `bundle install` to work. Probably because `rails` depends on `bundler`.
-That sudo check is neat, and I'd like to lift it; what's this script's license?