Chapter 3 of learning ruby on rails.