exercise from a book on ruby on rails