I use a MacBook Pro for work and pleasure on a day-to-day basis. Recently, I was asked to teach web students at a local high school. These students know html/graphics/flash/etc. The advanced students were ready for some server-side programming and database integration. I wanted the students to be able to get up and going quickly (for motivation reasons) and to create useful apps (using a database). I felt Sinatra to be a great fit for this. I created a Sinatra app for my uncle and his business. It was a joy to work with it and I was able to deploy quickly using Heroku.
My experience of using Sinatra on my Mac was straightforward. Like most things using Ruby and Mac: it just worked. However, I found out the students at the high school use MS Windows. Fortunately, I have a Windows XP virtual machine running in VMWare so I could prepare that way. I used to teach computer science and web development at Spokane Community College and am aware of teaching Ruby in a Windows lab environment. Things can get tricky at times - and preparing a Sinatra app on Windows XP was a little tricky.
Here I am to quickly document what I can about setting up Sinatra on a Windows environment.
- Grab the installer and install Ruby: http://rubyinstaller.org/
- Install Sinatra from the Command Prompt:
- c:> gem install sinatra
- Install sqlite3
- Go to http://www.sqlite.org/download.html and download the Precompiled Binaries for Windows:
- Unzip and look for these files. Copy them into the Ruby bin directory path c:\ruby\bin
- Install sqlite3-ruby gem
- c:> gem install sqlite3-ruby
- Install DataMapper
- c:> gem install dm-core
- c:> gem install do_sqlite3
- Code Reloading:
- Sinatra by default does not reload your code while you are editing and saving. Thus you have to restart sinatra server after changes = annoying!
- On the Mac I quickly found shotgun for my code reloading needs. However shotgun does not work on Windows. :(
- I then found out another gem that does code reloading on Windows: sinatra-reloader whew!
- c:> gem install sinatra-reloader
- Sinatra starter code:
- Put the code snippet (see below) into a file and save as: sinatra_starter.rb
- From command prompt, start the sinatra server:
- c:> ruby sinatra_starter.rb