from michael hartl's rails tutorial (chapter 2)