Giter VIP home page Giter VIP logo

rps_rails's Introduction

Rock, Paper, Scissors -- Rails

In this project, we'll practice basic Ruby, but within the context of Rails; so that input and output will happen via the browser rather than Terminal.

Setup

  1. Clone this project.

  2. Create your branch.

  3. Open the folder in Atom.

  4. Navigate to the folder in Terminal.

  5. Once you are inside the rps_rails folder in Terminal, run the command

    rails server
    

    If all goes well, you should see something like

    => Booting WEBrick
    => Rails 4.2.6 application starting in development on http://localhost:3000
    => Run `rails server -h` for more startup options
    => Ctrl-C to shutdown server
    [2016-04-17 09:54:29] INFO  WEBrick 1.3.1
    [2016-04-17 09:54:29] INFO  ruby 2.3.0 (2015-12-25) [x86_64-darwin15]
    [2016-04-17 09:54:29] INFO  WEBrick::HTTPServer#start: pid=2155 port=3000
    

    and the cursor should remain blinking (it should not return you to the command prompt). That means your server is running successfully. (If you do get kicked back to the command prompt, then you most likely have an old Rails server already running, which needs to be shut down. Find the old Terminal window and close it, or Ctrl-C to shut down the server.)

  6. Now that you have a running web server, you can visit your site. In Chrome, navigate to http://localhost:3000. You should see a page with links to click to start playing Rock, Paper, Scissors. However, if you click on them now, you'll see that the game doesn't work -- yet.

  7. In Atom, locate the file app/controllers/game_controller.rb. You will see two lines:

    @computer_move = "Replace this string with the correct value."
    
    @result = "Replace this string with the correct value."
    

    These dummy placeholder values are what you are seeing in Chrome. Change them, for example, to be hardcoded strings

    @computer_move = "rock"
    
    @result = "won"
    

    and play the game in Chrome.

  8. Your task: add logic to app/controllers/game_controller.rb to make the game work correctly.

rps_rails's People

Contributors

raghubetina avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.