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
16
votes
2 answers

How do I get params attributes in post?

I am using Sinatra with Ruby 1.8.7. I'm new to web development, so I don't totally understand get and post, but I got some stuff working. What I need to know next is how to interrogate params in post for certain attributes. In my main file, I…
dt1000
  • 3,684
  • 6
  • 43
  • 65
16
votes
1 answer

ActiveRecord::ConnectionNotEstablished - No connection pool for X

I can't make my sinatra/ruby app hosted on heroku works as desired. I fiddled with some setup trying to resolve this issue but so far no results. ActiveRecord::ConnectionNotEstablished - No connection pool for User: 2015-06-25T14:26:11.736854+00:00…
Jacek Kwiecień
  • 12,397
  • 20
  • 85
  • 157
16
votes
1 answer

Sinatra with optional query parameters

I want to create a Sinatra API route with optional query parameters.I'm able to add the query parameters as follows %r{^/mysql/data/(?)/start_time=(?\w*)/?} But the route corresponding to the above route is like…
NagaLakshmi
  • 715
  • 3
  • 12
  • 24
16
votes
2 answers

Rails: How do I require NumberHelper and make it work?

I'm trying to write a simple Sinatra thingy but I need ActionView::Helpers::NumberHelper from action pack. http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html The question is, how do I install and use it? irb(main):001:0>…
alamar
  • 18,729
  • 4
  • 64
  • 97
16
votes
4 answers

Passenger: internal server error

I installed Apache, Passenger and Sinatra and deployed an app. It gives error when trying to access: An error occurred while starting up the preloader: it did not write a startup response in time. Application root /var/www/html/test Environment…
SwiftMango
  • 15,092
  • 13
  • 71
  • 136
16
votes
1 answer

How do I specify Origin Whitelist Options in Sinatra using Rack/Protection

I have a web app, lets say http://web.example.com making a POST request to http://api.example.com. The api server is running the latest version of Sinatra with rack protection enabled. I am getting this error 'attack prevented by…
kelsmj
  • 1,183
  • 11
  • 18
15
votes
3 answers

using bundler to load different versions of gems for different platforms

So I am developing a Sinatra for both windows and linux. The problem is I'm using Thin instead of Webrick and eventmachine for windows only works with a pre-release version while linux uses the latest stable. in the gemfile you of course cannot…
indigo0086
  • 431
  • 6
  • 13
15
votes
1 answer

Passwords in git tree + Heroku + Github

I have a very basic application done in Sinatra I have deployed it in Heroku (http://frasesbarrio.heroku.com) There is a button for sharing in Facebook and in fact it can be used as a Facebook application. For Facebook authentification, my…
Jordi
  • 1,212
  • 2
  • 11
  • 25
15
votes
4 answers

Sinatra OPTIONS HTTP Verb

Does Sinatra support the OPTIONS HTTP verb? Something like: options '/' do response.headers["Access-Control-Allow-Origin"] = "*" response.headers["Access-Control-Allow-Methods"] = "POST" halt 200 end
Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232
15
votes
2 answers

What's the best way to profile a Sinatra application?

I'm trying to figure out what the best way to profile a Sinatra app is. I'd like a solution that would give me a time profile of all methods within a path, including the rendering of the haml. Has anyone profiled a Sinatra app? Any pointers?
Ecton
  • 10,702
  • 2
  • 35
  • 44
15
votes
2 answers

How do I use Sinatra to serve XML documents?

I have some XML documents that I'd like to server from Sinatra. I did some searching but couldn't find anything specific. I did find the builder gem but I don't want to build the document from scratch. I tried to do something like this get '/' …
Luis
  • 171
  • 1
  • 5
15
votes
1 answer

Replacing ActiveRecord::ConnectionAdapters::ConnectionManagement in ActiveRecord 5

We are upgrading a Sinatra application from ActiveRecord 4 to ActiveRecord 5. Previously we had this line: use ActiveRecord::ConnectionAdapters::ConnectionManagement This is because connections were not being cleaned up after requests completed.…
esilver
  • 27,713
  • 23
  • 122
  • 168
15
votes
4 answers

Before-filter for all POST requests in Sinatra?

Is there a way to create a "before" filter to capture and pre-process all POST requests in Sinatra?
Arman H
  • 5,488
  • 10
  • 51
  • 76
15
votes
1 answer

How can I give Sinatra a catchall, default route?

For a small developer documentation app, I'd like to set up a Sinatra app to just serve HAML files. After routes for CSS files and images, I want a route that tries to load a HAML file for any path you request. For example: /index loads…
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
14
votes
1 answer

Which library would provide the easiest OAuth 2.0 authentication for Sinatra

I'm going to implement a simple REST API wrapper around a service and would like to use Ruby with Sinatra for this task. The Idea is to have users authenticate / sign requests using two-legged OAuth (2.0). Should I try to use an authentication…
Marc Seeger
  • 2,717
  • 4
  • 28
  • 32