from chapter 3 of Mike Hartl's Ruby on Rails book