Rails Setup

Rails Setup

Due by midnight on Monday Feb 24th


First look at Rails and our web-app. Establish a working rails development environment on your own machine. Create a skeletal rails application on your own machine and test it locally using the mongrel web-server. Consistently defeat RandomPlayer at Connect Four in the RubyGame web-app.


It is vital for the remainder of the class that you each have access to your own Rails development machine. I use a Windows machine but Ruby and hence Rails too are platform independent so you should be able to use a Mac or Linux if you want to. However, I won't be able to field questions about installation unless on Windows.

It is also vital that we all use the same versions of Ruby and Rails. Currently, the CS department linux machines have Ruby 1.8.7 and Rails 2.2.2 (yes, the Rails framework has version numbers separate from Ruby). I actually develop against Ruby 1.8.6 but when deploying code to a CS host running Ruby 1.8.7 it all seems to work so we will assume that both Ruby 1.8.6 and Ruby 1.8.7 are acceptable to us and fix any compatibility issues if/when they arise. So your development machine MUST have:

  • Ruby 1.8.6 or Ruby 1.8.7
  • Rails 2.2.2 (no other version will do)
  • MySql 5.x. (On windows you get it as part of Instant Rails)
  • SqlLite 3. (On windows you get it as part of Instant Rails)
  1. Installation
      Windows - use Instant Rails 2.0
    1. Check out the Instant Rails web site and download the zip file under version 2.0.
    2. Don't let the zip file extract to the default path. Be sure to change the path to something short like C:\ruby. It will take a while to extract so be patient.
    3. Under your Instant Rails directory copy the file libmySQL.dll from mysql\bin to ruby\bin
    4. This screencast provides installation instructions.
    5. The versions of gems and rails in instant Rails aren't quite what we need so update them to the necessary versions as follows:
      1. In the Instant Rails GUI, click the I icon at the top-left corner and select Rails Applications - Open Ruby Console Window. IMPORTANT: you must ALWAYS use this command prompt for rails work and NEVER the regular windows one, so DO NOT CLOSE the instant Rails GUI.
      2. Make sure your internet connection is working before the next two steps, i.e. make sure you are online.
      3. Download version 1.3.5 of the rubygems zip file and extract it to your Instant Rails directory. Using the instant rails command prompt you opened in step 1.5.1 change directory to the rubygems folder you just extracted and enter: ruby setup.rb
      4. Enter (much patience required): gem install rails --version 2.2.2
    6. Check that the versions are correct using:
      1. gem -v (should be 1.3.5)
      2. rails -v (should be 2.2.2)
      3. ruby -v (should be 1.8.6)

      Mac or Linux
    1. See instrutions in Chapter 3 of the Agile Web Development with Rails (AWDwR) textbook and the following links: Locomotive which is like Instant Rails but for Mac, Leopard instructions for installing all the components separately, and Rails on Ubuntu

  2. Rails Tutorial

    Do the tutorial in chapters 5-8 of the Agile Web Development with Rails book (AWDwR). Ignore all the stuff about MySql on pages 63-66 and just use the default SqlLite3 for this tutorial. You can do more chapters if you want to get ahead for the next project but chapters 5-8 are enough for now. If you are unfamiliar with the MVC (Model View Controller) design pattern then make sure you read chapter 2 first (it's part of this week's assigned reading anyway).

    When you're finished and, more importantly, your Depot web-app is running correctly on your localhost, zip up your Depot directory into a file called depot and submit that in the usual way.

  3. Connect4Simpleton

    Write a class Connect4Simpleton that inherits from AgentBase and put it in a file called c4_simpleton_s14_your_name.rb. (So mine would be in file c4_simpleton_s14_julian_bishop.rb). In the game of Connect Four, a winning move makes 4-in-a-row and a blocking move prevents the opponent from having a winning move on its next turn. Connect4Simpleton has a keen eye but is otherwise rather stupid:

    • If the board contains a winning move then Connect4Simpleton wins.
    • If the board contains no winning move, but does contain a blocking move then Connect4Simpleton blocks.
    • If the board contains no winning or blocking move then Connect4Simpleton moves randomly.

    You should assume my solution to the Connect4 class when writing your Connect4Simpleton since mine is the one used in the web-app.

  4. RubyGame Web-app First Look
    1. Open your browser and navigate to http://wrath.cs.utexas.edu:3000/games. You will see a login screen where you should click on "Sign up" to create a user account for the site. Choose your user Login name sensibly as for the time being it will be used to identify your records on the screen and so be visible to other users.
    2. After signing up you should be redirected to a list of all the games that have been uploaded to the web-app. Play around with the web-app. Use the "Upload New Agent" link to upload your Connect4Simpleton. The "New Agent" form will ask you to give your agent a name. Name it "C4 Simpleton XXX S13" where XXX are your initials and do not include the quotation marks (so mine would be named C4 Simpleton JNB S14). In the Class field enter Connect4Simpleton and then select your file using the "Browse" button. Don't forget to tell the form that your player can play Connect Four!
    3. Use the "Play" button on the "All Games" page to play a game of Connect Four between your Connect4Simpleton as player1 and RandomPlayer as player2. Repeat this nine more times for a total of ten results and do not destroy your results (I can tell if you do). Even the results which are not what you want are of interrest to me. If your Connect4Simpleton is correct you should expect it to win every match although it is not impossible for it to be very unlucky and lose one.
    4. How was your user experience? Can you recommend any functionality improvements for the web-app? Put your answers in a file called functionality.txt. I'm not so interested in making it look pretty as I am in making it more functional - you're developers not web-designers. Instead focus on missing or superfluous information and lack of useability or features.
    5. Finally, you are free to view but not modify all the code in the web-app you have just been using: open a linux terminal window for one of the CS department machines and change directory to /u/z/users/julian/rails2_apps/rubygame and peruse the code most of which is under the app folder. Also check out the database diagram for the app which is implemented using MySql.

  5. Explore the Rails online documentation

    Explore www.rubyonrails.org, especially the documentation pages

Grading Criteria

Follow the tutorial and zip up and turn in the resulting Depot web-app to prove you are in a position to do rails development for the remainder of the class. As long as it works when I test it you will get full credit for this part of the project.

Your Connect4Simpleton should adhere to the specification and win consistently against RandomPlayer and your code should be as concise and elegant as possible.

Your suggestions in functionality.txt should be constructive, achievable, and not just window-dressing for the existing funtionality. A short bullet-pointed list is enough to get full credit for this part of the project.

Submission Checklist

  • depot
  • c4_simpleton_s14_your_name.rb
  • functionality.txt