Chapter 2 of railstutorial.org