CHIPS 4.6: Wordguesser on Rails
See how the same Wordguesser app looks when it is built with Rails instead of Sinatra. This is part of Module 4.
Gradescope online assignment β no code to turn in
This CHIPS is submitted as a Gradescope online assignment: you answer the questions directly on Gradescope. You do not need to turn in any code. You will want a copy of the starter repo,
saasbook/hw-rails-wordguesser, to explore (see Getting the Code) β the full walkthrough and questions are in itsREADME.md.
Goals
- Understand how Rails and Sinatra differ in how routes are defined and mapped to controller actions.
- Navigate a conventional Rails directory structure: models, controllers,
views, and
config/routes.rb. - See how Rails keeps state in the session and renders views by convention (Convention over Configuration).
- Appreciate the value of separating game logic from framework code β the
WordGuesserGameclass from CHIPS 3.7 drops into Rails unchanged, and so do its Cucumber scenarios.
What youβll do
The starter repo is a complete Rails version of the Wordguesser game. Run it,
play a few rounds, and read through the code, comparing each piece with your
Sinatra version. Work through the sections of the starter repoβs README.md
and answer the matching questions on Gradescope as you go.
Before you start
Complete CHIPS 3.7 and watch Module 4 Β§4.4β4.5.
Logistics
- Getting the code: nothing to submit, but see Getting the Code below to get your own private copy of the starter repo to explore.
- Submission: answer the questions on Gradescope (an online assignment, not a code upload) β see Submission. You may edit your answers as many times as you like before the deadline.
- Extensions: everyone automatically gets a 2-day no-penalty extension; see the extension policy.
- Collaboration: you may collaborate with your team of 4, and discuss high-level approaches with anyone. Sharing answers outside your team is academic misconduct. See the AI Use Policy below before using AI tools.
AI Use Policy
This assignment follows the course AI Policy, which will be published on this site before it is needed. Until then, the rule from the Syllabus applies: you must be able to explain everything you submit.
Getting the Code
Public starter repo: saasbook/hw-rails-wordguesser —
https://github.com/saasbook/hw-rails-wordguesser
GitHub makes it challenging to have a private fork of a public repository. These steps allow you to create a private space for you own work but still update from the starter code.
Clone the starter repo, then use gh
(see Local Development)
to create a private copy under your own GitHub account and
push the code to it. Replace YOUR_GITHUB_USERNAME with your
GitHub username:
git clone https://github.com/saasbook/hw-rails-wordguesser.git
cd hw-rails-wordguesser
git remote rename origin upstream
gh repo create YOUR_GITHUB_USERNAME/hw-rails-wordguesser --private --source=. --remote=origin --push
git remote set-url --push upstream DISABLED
After this, origin is your private repo and upstream
is the public starter repo. The last command disables pushing to
upstream, so git push always goes to your own
copy β never to the public starter repo.
Keeping your repo up to date
Your private repo is a snapshot: it does not follow the starter
repo. If we fix or add something in saasbook/hw-rails-wordguesser
after you copy it, you have to pull those changes in yourself. The
upstream remote you set up above is how you do that:
git fetch upstream
git fetch only downloads β it changes nothing in your working
copy. Review what you are about to take before merging it:
git diff --name-only HEAD upstream/main # just the names of the files that differ
git diff --stat HEAD upstream/main # the same list, plus how much changed in each
git diff HEAD upstream/main -- spec # the actual changes, limited to one file or directoryThen merge the upstream changes into your branch and push them to your private repo:
git merge upstream/main
git push origin main
If you and we edited the same lines, git stops and reports a conflict: open
each file it lists, keep the correct combination of both sides, delete the
<<<<<<< / ======= /
>>>>>>> markers, then git add
those files and git commit. Ask on Ed if a merge leaves you
stuck β don't start over and lose your work.
These commands assume the starter repo's default branch is main.
If git branch -r shows upstream/master instead, use
that name in the commands above.
View this assignment on bCourses.