Based on the Ruby on Rails tutorial by Michael Martl