Wordguesser on Rails

CHIP 4.6: Wordguesser on Rails

In a previous assignment, CHIPS 3.7 you created a simple Web app that plays the Wordguesser game.

More specifically:

  1. You wrote the app’s code in its own class, WordGuesserGame, which knows nothing about being part of a Web app.
  1. You used the Sinatra framework to “wrap” the game code by providing a set of RESTful actions that the player can take, with the following routes:

    • GET /new– default (“home”) screen that allows player to start new game
    • POST /create – actually creates the new game
    • GET /show – show current game status and let player enter a move
    • POST /guess – player submits a letter guess
    • GET /win – redirected here when show action detects game won
    • GET /lose – redirected here when show action detects game lost
  1. To maintain the state of the game between (stateless) HTTP requests, you stored a copy of the WordGuesserGame instance itself in the session[] hash provided by Sinatra, which is an abstraction for storing information in cookies passed back and forth between the app and the player’s browser.

In this assignment, you’ll reuse the same game code but “wrap” it in a simple Rails app instead of Sinatra.

Learning Goals

Understand the differences between how Rails and Sinatra handle various aspects of constructing SaaS, including:

  • how routes are defined and mapped to actions;
  • the directory structure used by each framework;
  • how an app is started and stopped;
  • how the app’s behavior can be inspected by looking at logs or invoking a debugger.

This site uses Just the Docs, a documentation theme for Jekyll.