This is chapter 3-9 of the Rails Tutorial Book