We are going to build a simple game. Users are allowed to choose Rock, Paper, or Scissors by visiting one of the following URLs:
And we will tell them whether they won or lost. Your target, in the end, is this:
https://rps-rcav-target.herokuapp.com
- First fork, and then clone.
cd
to the root folder of the application.bundle install
(or justbundle
for short).rails server
(or justrails s
for short).- Once the server has booted up successfully, visit http://localhost:3000 in Chrome. If all went well, you should see the "Welcome Aboard" page.
- Open up the entire folder of code in Sublime (on Windows, File โ Open Folder...; on Mac, you can select a folder using the usual File โ Open... dialog).
This is currently a brand new Rails app, with absolutely no routes, controllers, etc.
Add support for each of our three URLs one at a time. For each one,
- Complete the RCAV and display "Hi!" to prove that you did so. Make up whatever names you want for the controller and action.
- Now step back into the action and write some logic to determine whether the player won or lost. Put the computer move and the outcome into instance variables.
- In the view template, display the instance variables. Format it a little with some markup and some copy.
Once you have completed the above for all three URLs,
- On each page, add links to get to the other two pages (so that our users don't have to keep typing into the address bar).
- I dropped three images in the
public/assets/images
folder:rock.png
,paper.png
, andscissors.png
. Therefore, they are available to use (e.g., as thesrc=""
of<img>
s) at http://localhost:3000/assets/images/rock.png, etc. Use the images on your pages as you see fit. - I also dropped
bootstrap.css
in thepublic/assets/css
folder.<link>
to it inapp/views/layouts/application.html.erb
, and use Bootstrap styles to make everything look nicer. - Add a root URL such that visiting the bare domain, http://localhost:3000, defaults to playing rock.