Chapter 3 of rubyonrailstutorial.org