Rapid Prototyping with Sinatra

by Al Shaw

11 Reader Comments

Back to the Article
  1. Thanks for this - that really was a good introduction. I’ve done quite a lot of Rails already, so there was nothing scary there, but I can imagine that even someone with no backend experience would be able to follow your steps and get something running fairly quickly.
    Copy & paste the code below to embed this comment.
  2. An even easier install of Ruby on Mac OS X is to use RVM (Ruby Version Manager). Install RVM wiht one simple command:
    prompt> bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) Then you can install Ruby (1.8.7 or 1.9.2) by simply typing:
    prompt> rvm install 1.9.2 If using RVM you don’t need to use sudo to install gems.
    prompt> gem install sinatra
    Copy & paste the code below to embed this comment.
  3. Good intro.  I’ve been using Sinatra for prototyping web apps for a while now and agree that it’s the best tool for the job.  Someday I’ll write more on the topic and the tools I use, but for those interested, check out the following projects that allow for fast prototyping with Sinatra: * “My Git Deploy Workflow (for rapid prototyping)”:https://gist.github.com/735260#file_gitdeploy.md—Combining GIT and Sinatra make it easy to deploy your prototypes to users
    * “Serve”:https://github.com/jlong/serve—a small Rack-based web server and rapid prototyping framework for Web applications (specifically Rails apps)
    * “Faker”:https://github.com/stympy/faker—a simple gem that makes it easy to stuff your app with fake data
    * “Haml”:http://haml-lang.com/—Why write HTML if you can write HAML?
    * “Padrino”:http://www.padrinorb.com/guides/standalone-usage-in-sinatra—a nice lightweight framework you can use to bootstrap an app with. Start your app as a prototype, but then evolve it to a real app.  You can also use Padrino’s excellent “helpers”:http://www.padrinorb.com/guides/standalone-usage-in-sinatra standalone inside of Sinatra.
    Copy & paste the code below to embed this comment.
  4. You have to restart the server if you make changes to the ruby code (although not if you only make changes to the .erb files). That’s really a pain, even though it’s pretty quick. Kind of slows down the rapid prototyping. Is there a way around this? Rails has the “development” mode which is slower, but which lets you see changes without a server restart.
    Copy & paste the code below to embed this comment.
  5. @nyarlathotep Yes, that’s correct about the .erb files. There is gem called shotgun you can use which makes Sinatra work like Rails’ development mode reloading your code on every request. To use it, `sudo gem install shotgun` then start the app with `shotgun myapp.rb` instead of `ruby myapp.rb` and it should start running on port 9393.
    Copy & paste the code below to embed this comment.
  6. Another alternative that’s actually better than Shotgun is “Rerun”:https://github.com/alexch/rerun.  Rerun only restarts the server if an .rb or .ru file changes.  Shotgun reloads the code on each request.
    Copy & paste the code below to embed this comment.
  7. We’ve been doing something similar for a few years with XML/XSLT/CSS/jQuery. It’s only slightly less flexible, but it allows us to explore a variety of situations and data possibilities without needing to spin up a server. It also assists us by becoming the training environment once the solution is set and has the benefit of running just about anywhere, even off of a CD or thumb drive.
    Copy & paste the code below to embed this comment.
  8. Thanks for the great intro to Sinatra. I agree Nate RVM makes dealing with multiple versions of Ruby a breeze. Great links in the discussion too. I’m sure this will likely be the first foray into the terminal for many readers. I’d like to encourage any who are terminal novices (having come from a design background) that while it’s scary at first, it’s very empowering once you get familiar with it. This article is a great place to start.
    Copy & paste the code below to embed this comment.
  9. This is a great intro into the world of Sinatra. Our team has been developing in Sinatra for the last couple of years and have found it incredibly quick for small and medium-sized commercial sites. One of its key strengths (vs PHP which we used to use), is how easy it is for our designers to understand what is going on on the views and even write basic application logic themselves. Teamed with haml, git and rerun, it’s a dream development environment. In the last year we’ve built a couple of larger sites in Sinatra and although they’ve worked well, we’re also experimenting with Rails 3 to see if its ‘convention over configuration’  paradigm offers an advantage over the Sinatra’s relative anarchy for larger applications. At the moment, the jury’s still out.
    Copy & paste the code below to embed this comment.
  10. Would making a clickable prototype in Fireworks be much different, and if so, how? As a designer with a very beginning knowlegde on HTML/CSS an coding at all, the article, at a quick glance, looks like another batch of code to wrestle with, which is something I hope to avoid when making a quick, simple prototype.
    Copy & paste the code below to embed this comment.
  11. I’m just getting started with Rails so this going to be very handy. many thanks!
    Copy & paste the code below to embed this comment.