Ruby on Rails

Project: Sinatra Project

Introduction

You’ve seen how simple it can be to get something up and running using Sinatra, in these projects you will use the Caesar Cipher and either the Hangman or Mastermind games you built in the Ruby course to make a couple of web apps.

A note on deploying your apps

Deploying a Sinatra app to Heroku takes a little bit of work but the process is fairly straightforward. Instructions can be found here

your config.ru file should require your main application file (This will be something like web_guesser.rb in the jumpstart tutorial)

if you are using sinatra/reloader, you need to remove or comment out that line before pushing to Heroku. Alternatively you can add if development? to that line and Heroku will automatically know not to use it (and it will still work locally!).

after creating your Gemfile, you need to run bundle install and add/commit the files to git before pushing to Heroku.

Project 1: Caesar Cipher reloaded

Revisit the caesar cipher ruby script that you created during Ruby Building Blocks and use Sinatra to create a simple front-end for it.

Assignment

Start a new Sinatra project (you can begin by doing a simple hello world as in the Jumpstart tutorial, just to make sure everything is set up correctly)

You should be able to do this with only one view, and a couple of routes, but feel free to be as fancy as you like.

Student Solutions

Send us your solution so we can show others! Submit a link to the Github repo with your files in it here using any of the methods listed on the contributing page. Please include your partner’s github handle somewhere in the description if they would like attribution.

Project 2: Another Web-Game

Pick either Mastermind or Hangman and build a front end for it. This one might take a little more work, but it should be well within your grasp at this point. Have fun!

Assignment

The UI-implementation is up to you this time. Keeping them text-based is acceptable, but now that we’re on the web you can branch out with images to make something a little nicer.

You’ll probably want to go over the use of “sessions” within Sinatra again. Check the README and here.

Have fun! Don’t forget to make all of your friends play your game!

Extra Credit The free Heroku account only allows a limited number of projects, unless you add a credit card to your account (they won’t charge you, it’s just for identity confirmation). If you do add your information, you can have unlimited projects, but they still limit how many of them can be “awake” at one time. You might consider using Sinatra to make yourself a simple web-portfolio so that you can store all of these apps in one project.

Student Solutions

Send us your solution so we can show others! Submit a link to the Github repo with your files in it here using any of the methods listed on the contributing page. Please include your partner’s github handle somewhere in the description if they would like attribution.