The Game Tic-Tac-Toe in Ruby
- Node 8.16+ (download)
- Ruby 2.5+ (download)
- Rails 6+ (download)
- Yarn 1.20+ (download)
- SQLLite3 (included w/ Rails installer)
Navigate to the tictactoe
directory, then run rails server
; the running app is available at http://localhost:3000
- Install Ruby and Ruby on Rails
- Get intro to Ruby via Ruby in Twenty Minutes
- Start setting up Rails environment
- Initially installed this Bitnami bundle, but it did not appear to help
- Switched to RailsInstaller, but it came w/ the wrong version of Ruby ๐
- Ended up on the RubyInstaller page, and got Ruby + Devkit 2.7.2
- Also installed Yarn, because Rails needs it
- Create new Rails app w/ CLI
rails new tictactoe
- Boot Rails app w/ CLI
cd tictactoe; rails server
- Generate first controller
rails generate controller Welcome index
- This page helped with some of the Ruby syntax used in the template
- The initial Rails app structure is sufficient for this project, so I'm going to use the index page I just created to host the game. I've decided I'll use ERB and Ruby to help with templating, but for the actual page interaction, the app will use vanilla JavaScript (and the DOM).
- Generate a model to track game history -
rails generate model GameHistory num_ties:numeric num_p0_wins:numeric num_p1_wins:numeric
- Run migration -
rails db:migrate