From Chapter 3 on of Rails tutorial.