Chapter 2 of tutorial from railstutorial.org