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

Sinatra public assets not available when uploading to Heroku

I've just started working on a simple Sinatra app and when uploading it to Heroku. None of the files in the public folder seem to be available but it works fine locally. Are there any obvious reasons this might be happening? Right now the code is…
socratic_singh
  • 183
  • 1
  • 13
2
votes
1 answer

Ruby Sinatra not showing output in browser for the first part of any IF statement or ANYTHING before the ELSE / END of the IF Statement

Using Sinatra, for whatever reason, the result if number > 1000, is NOT outputting to browser. It immediately shows "It took 0 tries to guess your number 10000." for example. So while the if statement works by NOT executing the until loop, it won't…
David Cahill
  • 1,477
  • 1
  • 10
  • 12
2
votes
2 answers

Unicode character sent to server is returned as garbage

Update: After further investigation I've managed to narrow the problem down to the json encoder. Passing the input straight through works fine, but passing it through MultiJson.encode is what's causing the problem. I'm sending the following up to a…
twaddington
  • 11,607
  • 5
  • 35
  • 46
2
votes
1 answer

Authorisation for Sinatra via CanCan

I am trying to get some auth mechanism working for my webapp (written in Sinatra). Currently I am playing around with sinatra-can which looks great. The issue I now face is that I need access to the specific model from the can method. Lets say I…
sontags
  • 3,001
  • 3
  • 19
  • 25
2
votes
0 answers

Using ActiveRecord models from lib directory in Rails application

How can I access models from a class in lib directory in rails application? I'm currently getting a uninitialized constant ClassName::ModelName when trying to access models. The error occurs when I try to run migrations(I'm transferring a Sinatra…
roman
  • 5,100
  • 14
  • 44
  • 77
2
votes
2 answers

Example of an Presenter using Ruby's Sinatra

I'm having trouble understanding how to implement the Presenter pattern alongside MVC using Sinatra. I've read lots of posts and none really are focused on the specific use cases i'm interested in. Just to be clear I'm already using the MVC pattern…
Integralist
  • 2,161
  • 1
  • 32
  • 50
2
votes
1 answer

How to load forked github repo as gem in sinatra/rack application

I'm trying to use a gem called "rbing" but there is an issue with it and the project has been abandoned but someone made a fix in a repo so I decided to use bundler to specify the new version. gem "rbing", :git =>…
Adam Bronfin
  • 1,209
  • 3
  • 27
  • 43
2
votes
1 answer

Arduino POST ERROR bad Request-Line `'

I am making a web application to host JSON data POSTed from an Arduino to be hashed and stored in a database. I am having an issue with the POST request to the web app being sent from the Arduino but I can't put my finger on it. The error being…
pdago
  • 107
  • 2
  • 9
2
votes
0 answers

render html.erb template in sinatra

How can render an html.erb template in sintara? For example, this works fine for a file named payment.erb: <%= render erb :payment %> The file I'm trying to use is named payment.html.erb, so what is the syntax for that render line?
Martin
  • 134
  • 1
  • 2
  • 12
2
votes
1 answer

How to set application_name with sinatra/sequel

I'm setting application_name in my connection string like so: DB = Sequel.connect(:adapter=>'postgres', :host=> 'localhost', :database=>'blah', :user=>'gator', :application_name => 'blahwebapp') However, when I view the pg_stat_activity or any…
Gator
  • 720
  • 5
  • 10
2
votes
1 answer

Sinatra + Rack:Session:Pool

I am using Rack:Session:Pool for memory based sessions. I would like to access the pool instance variables that is contacted in Rack:Session:Pool so I can see all the active session and contained data. How can I do that from within Sinatra or on the…
Peter
  • 95
  • 7
2
votes
1 answer

Rendering HTML file in Views folder results in a string, Sinatra

I have admin.html in my views folder. How do I get to render it by get '/admin/?' do require_logged_in send_file 'views/admin.html' //?? end but even while following "How to render a plain HTML file with Sinatra?", I end up with the text of…
Daryll Santos
  • 2,031
  • 3
  • 22
  • 40
2
votes
1 answer

Using Blocks in erb's (Sinatra, not Rails)

I would like to use the ruby block/yield concept in an erb (to be specific, so that I can use form_helpers). When I do so I get syntax errors, but not in my erb code; in the outputted code once erb's have been processed. For example, let's say I…
Pat Newell
  • 2,219
  • 2
  • 18
  • 23
2
votes
0 answers

Setup Apache/Passenger under Sub-URI when the base URI is handled by another server

I'm trying to setup a server for a Sinatra application with Apache and Phusion Passenger. The catch is, the server is supposed to be served from a sub-URI (say example.com/example), and the base URI (example.com) is served from another machine which…
user2261892
  • 188
  • 7
2
votes
0 answers

How do I set a Sinatra session from JQuery?

I am trying to create a session from JQuery to my Sinatra backend. When I send a POST request outside of Ajax, using something like POSTman, I am able to set a session, but when I send via JQuery, I just get NULL in return. How do I create a session…
Daryll Santos
  • 2,031
  • 3
  • 22
  • 40
1 2 3
99
100