from chapter3 of ruby on rails tutorial