Questions tagged [sinatra]

Sinatra is a Domain Specific Language (DSL) for quickly creating web applications in Ruby with minimal effort. It is an alternative to other Ruby web application frameworks such as Ruby on Rails, Nitro, Camping, and Rango.

Sinatra is a small and flexible designed and developed by Blake Mizerany (bmizerany) in California. The project was financed mainly by , and Engine Yard in the past and is now taken care of by .

It does not follow the typical model–view–controller pattern used in other frameworks; instead, Sinatra focuses on providing a small set of functionality to help you deal with common web tasks such as templates, routes, sessions, cookies and more.

Hello World with Sinatra:

require 'sinatra'

get '/hi' do
  "Hello World!"
end

Books:

Websites:

5369 questions
372
votes
18 answers

Separate REST JSON API server and client?

I'm about to create a bunch of web apps from scratch. (See http://50pop.com/code for overview.) I'd like for them to be able to be accessed from many different clients: front-end websites, smartphone apps, backend webservices, etc. So I really want…
sivers
  • 3,833
  • 3
  • 14
  • 7
188
votes
8 answers

Using Sinatra for larger projects via multiple files

It seems that in Sinatra all route handlers are being written into a single file, if I understand right it acts as a one large/small controller. Is there any way to split it into separate independent files, so when let's say somebody calls "/" - one…
spacemonkey
  • 19,664
  • 14
  • 42
  • 62
162
votes
18 answers

Gem installation error: You have to install development tools first (Windows)

this question is for Windows I tried installing the gem 'sinatra-websocket', but when I ran gem install sinatra-websocket, I got this error... ERROR: Failed to build gem native extension ... along with ... C:/Ruby193/bin/ruby.exe extconf.rb checking…
Generic_User_ID
  • 1,067
  • 2
  • 13
  • 16
143
votes
14 answers

Serving static files with Sinatra

I have one page website only using HTML, CSS and JavaScript. I want to deploy the app to Heroku, but I cannot find a way to do it. I am now trying to make the app working with Sinatra. . |-- application.css |-- application.js |-- index.html |--…
TK.
  • 27,073
  • 20
  • 64
  • 72
123
votes
9 answers

How to get Sinatra to auto-reload the file after each change?

I am using # my_app.rb load 'index.rb' and start the sever like this ruby my_app.rb but it never reload any changes I made in index page. Did I miss anything here?
ez.
  • 7,604
  • 5
  • 30
  • 29
110
votes
4 answers

EventSource / Server-Sent Events through Nginx

On server-side using Sinatra with a stream block. get '/stream', :provides => 'text/event-stream' do stream :keep_open do |out| connections << out out.callback { connections.delete(out) } end end On client side: var es = new…
Lukas Mayer
  • 1,117
  • 2
  • 8
  • 6
75
votes
4 answers

Foreman: Use different Procfile in development and production

I have a homemade Sinatra application for which I intend to use Heroku to host it. I use foreman and shotgun in development, with the following Procfile: web: shotgun config.ru -s thin -o 0.0.0.0 -p $PORT -E $RACK_ENV It works great with both…
Arnaud Leymet
  • 5,995
  • 4
  • 35
  • 51
68
votes
3 answers

Sinatra vs. Rails

I've worked through some of the Sinatra and Rails samples, but I'm having a hard time figuring out which features belong to which technology. What specifically do I gain by using Sinatra/Rails? Is it just ActionPack/ActionView? Correct me if I'm…
LoveMeSomeCode
  • 3,888
  • 8
  • 34
  • 48
68
votes
12 answers

Why is this RMagick call generating a segmentation fault?

I've been banging my head against the wall for the better part of an hour trying to figure out what's going wrong here, and I'm sure (or rather hoping) it's something fairly obvious that I'm overlooking. I'm using Ruby 1.9.1, Sinatra 1.0, and…
Grant Heaslip
  • 967
  • 2
  • 10
  • 16
59
votes
3 answers

Sinatra - API - Authentication

We going to develop a little API application in Sinatra. What are the authentication options available to secure the API calls?
Saim
  • 2,471
  • 5
  • 30
  • 43
59
votes
7 answers

Capistrano asks for password when deploying, despite SSH keys

My ssh keys are definitely set up correctly, as I'm never prompted for the password when using ssh. But capistrano still asks for a password when deploying with cap deploy. It doesn't ask for the password when I setup with cap deploy:setup though,…
ehsanul
  • 7,737
  • 7
  • 33
  • 43
56
votes
4 answers

Logging in Sinatra?

I'm having trouble figuring out how to log messages with Sinatra. I'm not looking to log requests, but rather custom messages at certain points in my app. For example, when fetching a URL I would like to log "Fetching #{url}". Here's what I'd…
Kyle Fox
  • 3,133
  • 4
  • 23
  • 26
50
votes
5 answers

Is Sinatra multi threaded?

Is Sinatra multi-threaded? I read else where that "sinatra is multi-threaded by default", what does that imply? Consider this example get "/multithread" do t1 = Thread.new{ puts "sleeping for 10 sec" sleep 10 # Actually make a call to…
ch4nd4n
  • 4,110
  • 2
  • 21
  • 43
48
votes
10 answers

Bundler not working with rbenv, could not find [gem]

I've just made the switch from rvm to rbenv and I'm trying to use bundler for gem management. After running bundle install and trying to run a simple sinatra app (ruby app.rb), I get this: Could not find haml-3.1.4 in any of the sources Run `bundle…
Uri
  • 2,306
  • 2
  • 24
  • 25
47
votes
2 answers

Set default content_type for Sinatra

In Sinatra is it possible to make content_type 'application/json' the default? Because I'm building a REST API.
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
1
2 3
99 100