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
2
votes
1 answer

Capistrano deployment error at task create_release

Good morning fellow developers ! Here I am for my very first post on Stackoverflow ! I have a problem deploying a Sinatra application, and can't figure out why it doesn't work, so I might need a little help from one of you. When I run the following…
2
votes
1 answer

Sinatra::ConfigFile, NoMethodError - undefined method

I set up the ConfigFile extension exactly(?) as proposed, but I'm getting the following error: App 32163 stderr: NoMethodError - undefined method `title' for Testing:Class: app.rb # Bundler require "rubygems" require "bundler/setup" #…
user3094719
  • 297
  • 4
  • 16
2
votes
1 answer

Selecting a specific div element with Xpath and Nokogiri?

I am relatively new to parsing and would like to get more practice. I want to parse the following URL: http://www.goodreads.com/quotes/tag/hard-work. I want to grab all quotes tagged "hard-work". This is what the site code breaks down to:
Uzzar
  • 705
  • 1
  • 12
  • 24
2
votes
1 answer

JRuby, Sinatra, Warbler app - HTTP PATCH request fails with 501 error

I've created a simple web service using JRuby 1.7.4, Sinatra 1.4.4 and Rack 1.5.2. This web service responds to GET, POST, PATCH and DELETE requests with a simple message "Hello world using [request-type]". I started Rack and tested all the request…
Sandeep M
  • 2,942
  • 2
  • 13
  • 17
2
votes
1 answer

How to serve images from Riak

I have a bunch of markdown documents in Riak, which I'm exposing via a small Sinatra API with basic search functionality etc. Each document has an associated image, also stored in Riak (in a different bucket). I'd like to have a client app display…
Russell
  • 12,261
  • 4
  • 52
  • 75
2
votes
1 answer

Ruby Sinatra: redirect page not working?

The problem lies in the following code ("routes.rb"). post 'download_csr' do file_name = File.dirname(__FILE__) + '/cert.csr' File.open(file_name, 'w') do |f| f.write params[:csr] end send_file file_name, :disposition =>…
user180574
  • 5,681
  • 13
  • 53
  • 94
2
votes
1 answer

Fibers and multiple http requests in Sinatra

I have problems understanding what is happening when calling external APIs using the fibers model with eventmachine. I have this code in Sinatra: get '/' do conn = Faraday.new 'http://slow-api-call' do |con| con.adapter :em_http end resp =…
Ron
  • 2,215
  • 3
  • 22
  • 30
2
votes
1 answer

Simple search form for my blog with ruby and sinatra

I'm using sequel. In my app.rb, I wrote get '/search' do @post = Post.find(:Title => "%#{params[:query]}%") erb :'layout' end Layout.erb

endritgr
  • 21
  • 2
2
votes
2 answers

AngularJS and sinatra CORS

I am trying to do a post using AngularJS $http.post('http://localhost:9393/doRegister',$scope.newUser).success (data)=> alert data To a sinatra controller post '/doRegister' do data = request.body.read return data.password …
kodeslacker
  • 129
  • 10
2
votes
3 answers

Creating widgets for dashing

I`m trying to create a widget for dashing (http://shopify.github.io/dashing/) for displaying 4 values: value1 value2 value3 value4 I have copied the contents of the text widget and added the following to the widget.html

Spanglish
  • 119
  • 1
  • 2
  • 13

2
votes
4 answers

mac os x 10.9 - brew server requires sinatra error

I want to run brew server on my Mac OS X Mavericks, but it throws an error: MacBook-Pro-Dmitri:bin dmitri$ brew server Error: Sinatra required but not found To install: /usr/bin/gem install sinatra The problem is that Sinatra is already…
Kosmetika
  • 20,774
  • 37
  • 108
  • 172
2
votes
2 answers

Insert HAML into a Sinatra helper

I'm writing a helper for a small Sinatra app that prints some gaming cards stored as hash in an array. Every card has this structure: { card: 'Ace', suit: :spades, value: 11 } and the filename of the card image is "spades_11.jpg". I'm writing a…
Roberto Pezzali
  • 2,484
  • 2
  • 27
  • 56
2
votes
3 answers

How to refactor this Ruby sanitize hash method to make it more idiomatic?

This method takes a hash and returns a new hash without sensitive information. It does not modify the hash passed in. Is there a more Ruby-like, idiomatic way of doing it? def sanitize hash new_hash = hash.dup protected_keys = [ :password,…
B Seven
  • 44,484
  • 66
  • 240
  • 385
2
votes
1 answer

Sinatra + Fibers + EventMachine

I would like to know to to pause a Root Fiber in ruby (if possible). I have this Sinatra app, and I am making async calls to an external API with EventMachine. I don't want to respond to the client until the api responds me. For example, sleeping…
Ron
  • 2,215
  • 3
  • 22
  • 30
2
votes
2 answers

how to make a sinatra app run in rails 4?

I have a Sinatra app and I'd like to start building new functionality in Rails while still supporting the existing Sinatra functionality. I've tried the following strategies: sinatra's rackup routes some requests to rails and some to…
glamouracademy
  • 103
  • 2
  • 8
1 2 3
99
100