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:
- You wrote the app’s code in its own class,
WordGuesserGame, which knows nothing about being part of a Web app.
-
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 gamePOST /create– actually creates the new gameGET /show– show current game status and let player enter a movePOST /guess– player submits a letter guessGET /win– redirected here whenshowaction detects game wonGET /lose– redirected here whenshowaction detects game lost
- To maintain the state of the game between (stateless) HTTP requests, you stored a copy of the
WordGuesserGameinstance itself in thesession[]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.