code from learning ruby on rails