Adding Postgres and ActiveRecord
Getting started - adding dependencies to your project
Guides, tutorials and labs to accompany CMU's Programming for Online Prototypes (49-714).
Everything you need to know about building microservices for the web with Ruby and Sinatra.
Sinatra is a framework written in the Ruby language. It’s designed as a simple, but very powerful and flexible way to build web-delivered application without a lot of setup, configuration or effort. Basically it’s quick and easy to get a web service up and running with Sinatra.
“DSL (domain specific language) for quickly creating web applications in Ruby with minimal effort.” 1
It can be used to quickly make anything from your own dynamic site to an API to open up data to other services. You can find out more on the project site: http://sinatrarb.com/
Sinatra is a Gem or library that extends the core functionality of the Ruby programming language and allows you to map incoming web requests to blocks of Ruby code.To do this, it builds on a Rack. Rack is a ‘webserver interface’ that basically allows a structured way of allowing Ruby frameworks to interact with HTTP or Web communications. It helps you handle any HTTP request and the pipeline of activities that you might need to address, such as authentication, caching and more, to deliver a great web-based software experience.
There are lots of other web-application frameworks out there. For example, theres:
All that is to say, is that there are a lot of options out there for you to choose. I recommend Sinatra because:
To illustrate this further, compare Sinatra to a basic Express script (example taken from: http://www.mervine.net/notes/sinatra-vs-express):
Sinatra
require 'sinatra'
get '/' do
"Hello World"
end
Express
var app = require('express');
app.get('/', function(req, res) {
res.send("Hello World!");
});
app.listen(8000);
Doesn’t Sinatra look much easier to write? It’s clearer, cleaner and simpler to read and understand.
Here’s another reason. In the image below you’ll see the default files included in Sinatra versus Ruby on Rails. Ruby on Rails has a lot more. Because it’s designed to encourage the use of web-development conventions. These conventions mean you have a LOT more to learn and a lot more to setup when you want to work with Ruby on Rails.
The good news is, you can easily adapt what you learn from working with Sinatra to Ruby on Rails. This means that if your web project grows, you can easily scale to Ruby on Rail’s more complex framework later.