sinatra - Classy web-development dressed in a DSL (official / canonical repo) Sinatra

Any success with Sinatra working together with EventMachine WebSockets?

I have been using Sinatra for sometime now and I would like to add some realtime features to my web-app by pushing the data via websockets.

I have successfully used the gem 'em-websocket' on its own, but have not been able to write one ruby file that has a sinatra web server AND a web-socket server.

I've tried spinning the run! or start! methods off in separate threads with no success.

Has anyone gotten this to work?

I want to have them in the same file as I can then share variables between the two servers.


Source: (StackOverflow)

How do I get Sinatra to refrain from adding the X-Frame-Options header?

I am using Sinatra to return some IFRAME contents, and I'd like to allow cross-domain src. Unfortunately, Sinatra is automatically adding an X-Frame-Options header to my response. How do I turn that off?

Source: (StackOverflow)

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 wrong, but I COULD just use Webrick/Mongrel and serve up my .erb files right? And I could use ActiveRecord technology in those files and still access post variables, session state and querystring variables right?

So, what I'm asking you guys is, if I start with the PHP-like scenario above; Webrick + ERB + ActiveRecord, what do I gain by using Sinatra? And what do I further gain by using Rails?

Source: (StackOverflow)

Contact form in ruby, sinatra, and haml

I'm new to all three, and I'm trying to write a simple contact form for a website. The code I have come up with is below, but I know there are some fundamental problems with it (due to my inexperience with sinatra). Any help at getting this working would be appreciated, I can't seem to figure out/find the documentation for this sort of thing.

haml code from the contact page:

%form{:name => "email", :id => "email", :action => "/contact", :method => "post", :enctype => "text/plain"}
        %label{:for => "message[name]"} Name:
        %input{:type => "text", :name => "message[name]", :class => "text"}
        %label{:for => "message[mail]"} Mail:
        %input{:type => "text", :name => "message[mail]", :class => "text"}
        %label{:for => "message[body]"} Message:
        %textarea{:name => "message[body]"}
    %input{:type => "submit", :value => "Send", :class => "button"}

And here is my code in sinatra's app.rb:

require 'rubygems'
require 'sinatra'
require 'haml'
require 'pony'

    get '/' do
        haml :index

    get '/contact' do
        haml :contact

    post '/contact' do
        name = #{params[:name]}
        mail = #{params[:mail]}
        body = #{params[:body]}     
        Pony.mail(:to => '*emailaddress*', :from => mail, :subject => 'art inquiry from' + name, :body => body) 

Source: (StackOverflow)

How do you debug a Sinatra app like a Rails app?

In my main Sinatra controller, I want to debug the params hash after it is POSTed from a form.

I have added:

puts params.inspect


set :logging, :true

The params.inspect works if everything goes well. But if an error happens before the controller is executed I'm not getting any information about the error like I would in Rails by default.

What's the best way to get useful debug info?

This example did not work at all (the app wouldn't even start after I added this code):

configure do 
  Log = Logger.new("sinatra.log")
  Log.level  = Logger::INFO 

followed by:

Log.info "#{@users.inspect}"

Source: (StackOverflow)

Passing parameters to erb view

I'm trying to pass parameters to an erb view using Ruby and Sinatra.

For example, I can do:

get '/hello/:name' do
  "Hello #{params[:name]}!"

How do I pass :name to the view?

get '/hello/:name' do
  erb :hello

And how do I read the parameters inside view/hello.erb?


Source: (StackOverflow)

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 install` to install missing gems.

Running bundle install again had no effect. Also tried bundle update as suggested by another question response.

This is my Gemfile:

source "http://rubygems.org"

gem "sinatra"
gem "haml"

This is what bundle show produces

* bundler (1.0.22)
* haml (3.1.4)
* rack (1.4.1)
* rack-protection (1.2.0)
* sinatra (1.3.2)
* tilt (1.3.3)

This is what my app requires:

require "rubygems"
require "bundler/setup"
require 'sinatra'

I'm convince that this is some kind of path issue where bundler and rbenv aren't playing along. I've tried looking through rbenv's documentation but was not able to find to anything.

Note: In a different sinatra app I get the following when trying to run it:

Could not find addressable-2.2.7 in any of the sources
Run `bundle install` to install missing gems.

Supplemental info

echo $PATH

which bundle


If I do bundle install --system it works. Although I can't see this as being a viable solution.

Source: (StackOverflow)

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 Third party API using HTTP NET or whatever.
  "multi thread"

get "/dummy" do

If I access "/multithread" and "/dummy" subsequently in another tab or browser then nothing can be served(in this case for 10 seconds) till "/multithread" request is completed. In case activity freezes application becomes unresponsive.

How can we work around this without spawning another instance of the application?

Source: (StackOverflow)

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, strangely enough. It would make the deployment cycle so much smoother without a password prompt.

Specifics: I'm deploying a Sinatra app to a Dreamhost shared account (which uses Passenger). I had followed a tutorial for doing so long back, which worked perfectly back then. Something broke since. I'm using capistrano (2.5.9) and git version Here's my Capfile:

load 'deploy' if respond_to?(:namespace) # cap2 differentiator

set :user, 'ehsanul'
set :domain, 'jellly.com'

default_run_options[:pty] = true

# the rest should be good
set :repository,  "ehsanul@jellly.com:git/jellly.git"
set :deploy_to, "/home/ehsanul/jellly.com"
set :deploy_via, :remote_cache
set :scm, 'git'
set :branch, 'deploy'
set :git_shallow_clone, 1
set :scm_verbose, true
set :use_sudo, false

server domain, :app, :web

namespace :deploy do
  task :migrate do
    run "cd #{current_path}; /usr/bin/rake migrate environment=production"
  task :restart do
    run "touch #{current_path}/tmp/restart.txt"

after "deploy", "deploy:migrate"

And here's the output of what happens when I cap deploy, upto the password prompt:

$ cap deploy
  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote ehsanul@jellly.com:git/jellly.git deploy"
  * executing "if [ -d /home/ehsanul/jellly.com/shared/cached-copy ]; then cd /home/ehsanul/jellly.com/shared/cached-copy && git fetch  origin && git reset  --hard ea744c77b0b939d5355ba2dc50ef1ec85f918d66 && git clean  -d -x -f; else git clone  --depth 1 ehsanul@jellly.com:git/jellly.git /home/ehsanul/jellly.com/shared/cached-copy && cd /home/ehsanul/jellly.com/shared/cached-copy && git checkout  -b deploy ea744c77b0b939d5355ba2dc50ef1ec85f918d66; fi"
    servers: ["jellly.com"]
    [jellly.com] executing command
 ** [jellly.com :: out] ehsanul@jellly.com's password:
 ** [jellly.com :: out]
 ** [jellly.com :: out] remote: Counting objects: 7, done.
remote: Compressing objects: 100% (4/4), done.

What could be broken?

Source: (StackOverflow)

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 -p $PORT -E $RACK_ENV

It works great with both development and production. But the thing is, I don't want to use shotgun in production since it's too slow.

Can we use separate Procfile configurations for both dev and prod?

Source: (StackOverflow)

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 like:

  • The ability to specify log levels (ex: logger.info("Fetching #{url}"))
  • In development and testing environments, the messages would be written to the console.
  • In production, only write out messages matching the current log level.

I'm guessing this can easily be done in config.ru, but I'm not 100% sure which setting I want to enable, and if I have to manually create a Logger object myself (and furthermore, which class of Logger to use: Logger, Rack::Logger, or Rack::CommonLogger).

(I know there are similar questions on StackOverflow, but none seem to directly answer my question. If you can point me to an existing question, I will mark this one as a duplicate).

Source: (StackOverflow)

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) }

On client side:

var es = new EventSource('/stream');
es.onmessage = function(e) { $('#chat').append(e.data + "\n") };

When i using app directly, via http://localhost:9292/, everything works perfect. The connection is persistent and all messages are passed to all clients.

However when it goes through Nginx, http://chat.dev, the connection are dropped and a reconnection fires every second or so.

Nginx setup looks ok to me:

upstream chat_dev_upstream {

server {
  listen       80;
  server_name  chat.dev;

  location / {
    proxy_pass http://chat_dev_upstream;
    proxy_buffering off;
    proxy_cache off;
    proxy_set_header Host $host;

Tried keepalive 1024 in upstream section as well as proxy_set_header Connection keep-alive;in location.

Nothing helps :(

No persistent connections and messages not passed to any clients.

Source: (StackOverflow)

Separate REST JSON API server and client? [closed]

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 a JSON REST API for each one.

Also, I prefer working on the back-end, so I daydream of me keeping my focus purely on the API, and hiring someone else to make the front-end UI, whether a website, iPhone, Android, or other app.

Please help me decide which approach I should take:


Make a very standard Rails web-app. In the controller, do the respond_with switch, to serve either JSON or HTML. The JSON response is then my API.

Pro: Lots of precedent. Great standards & many examples of doing things this way.

Con: Don't necessarily want API to be same as web app. Don't like if/then respond_with switch approach. Mixing two very different things (UI + API).


Make a JSON-only REST API server. Use Backbone or Ember.js for client-side JavaScript to access API directly, displaying templates in browser.

Pro: I love the separation of API & client. Smart people say this is the way to go. Great in theory. Seems cutting-edge and exciting.

Con: Not much precedent. Not many examples of this done well. Public examples (twitter.com) feel sluggish & are even switching away from this approach.


Make a JSON-only REST API server. Make a basic HTML website client, that accesses the REST API only. Less client-side JavaScript.

Pro: I love the separation of API & client. But serving plain HTML5 is quite foolproof & not client-intensive.

Con: Not much precedent. Not many examples of this done well. Frameworks don't support this as well. Not sure how to approach it.

Especially looking for advice from experience, not just in-theory.

Source: (StackOverflow)

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 RMagick 2.13.1. ImageMagick and RMagick are correctly installed and functional—I've successfully manipulated and saved images from irb.

The relevant part of the params array (formatting changes for the sake of readability):

        :head=>"Content-Disposition: form-data; name=\"admin_user_new_image_file\"; filename=\"freddie-on-shetland-pony.png\"\r\nContent-Type: image/png\r\n"

The relevant code:

post "/admin/user/:account_name/image/new/" do
  if params[:admin_user_new_image_file][:tempfile]
    thumbnail = Magick::Image.read("png:"+params[:admin_user_new_image_file][:tempfile].path).first

The error (line 229 is the line starting with "thumbnail = ":

config.ru:229: [BUG] Segmentation fault
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10.3.0]

-- control frame ----------
c:0042 p:---- s:0196 b:0196 l:000195 d:000195 CFUNC  :read
c:0041 p:0121 s:0192 b:0192 l:001ab8 d:000191 LAMBDA config.ru:229
c:0040 p:---- s:0189 b:0189 l:000188 d:000188 FINISH
c:0039 p:---- s:0187 b:0187 l:000186 d:000186 CFUNC  :call
c:0038 p:0018 s:0184 b:0184 l:001d78 d:000183 BLOCK  /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:865
c:0037 p:---- s:0182 b:0182 l:000181 d:000181 FINISH
c:0036 p:---- s:0180 b:0180 l:000179 d:000179 CFUNC  :instance_eval
c:0035 p:0016 s:0177 b:0175 l:000174 d:000174 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:521
c:0034 p:0024 s:0171 b:0171 l:000148 d:000170 BLOCK  /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:500
c:0033 p:---- s:0169 b:0169 l:000168 d:000168 FINISH
c:0032 p:---- s:0167 b:0167 l:000166 d:000166 CFUNC  :catch
c:0031 p:0140 s:0163 b:0163 l:000148 d:000162 BLOCK  /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:497
c:0030 p:---- s:0154 b:0154 l:000153 d:000153 FINISH
c:0029 p:---- s:0152 b:0152 l:000151 d:000151 CFUNC  :each
c:0028 p:0073 s:0149 b:0149 l:000148 d:000148 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:476
c:0027 p:0076 s:0141 b:0141 l:000140 d:000140 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:601
c:0026 p:0009 s:0137 b:0137 l:000138 d:000136 BLOCK  /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:411
c:0025 p:---- s:0135 b:0135 l:000134 d:000134 FINISH
c:0024 p:---- s:0133 b:0133 l:000132 d:000132 CFUNC  :instance_eval
c:0023 p:0012 s:0130 b:0130 l:000121 d:000129 BLOCK  /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:566
c:0022 p:---- s:0128 b:0128 l:000127 d:000127 FINISH
c:0021 p:---- s:0126 b:0126 l:000125 d:000125 CFUNC  :catch
c:0020 p:0013 s:0122 b:0122 l:000121 d:000121 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:566
c:0019 p:0098 s:0115 b:0115 l:000138 d:000138 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:411
c:0018 p:0019 s:0108 b:0108 l:000107 d:000107 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:399
c:0017 p:0014 s:0104 b:0104 l:000103 d:000103 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/showexceptions.rb:24
c:0016 p:0150 s:0098 b:0098 l:000097 d:000097 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/methodoverride.rb:24
c:0015 p:0031 s:0092 b:0092 l:000091 d:000091 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/commonlogger.rb:18
c:0014 p:0018 s:0084 b:0084 l:002080 d:000083 BLOCK  /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:979
c:0013 p:0032 s:0082 b:0082 l:000081 d:000081 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:1005
c:0012 p:0011 s:0078 b:0078 l:002080 d:002080 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:979
c:0011 p:0100 s:0074 b:0074 l:000ff0 d:000ff0 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/lint.rb:47
c:0010 p:0022 s:0068 b:0068 l:000067 d:000067 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/lint.rb:35
c:0009 p:0014 s:0064 b:0064 l:000063 d:000063 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/showexceptions.rb:24
c:0008 p:0031 s:0058 b:0058 l:000057 d:000057 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/commonlogger.rb:18
c:0007 p:0014 s:0050 b:0050 l:000049 d:000049 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/content_length.rb:13
c:0006 p:0320 s:0042 b:0042 l:000041 d:000041 METHOD /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/handler/webrick.rb:48
c:0005 p:0256 s:0030 b:0030 l:000029 d:000029 METHOD /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111
c:0004 p:0382 s:0020 b:0020 l:000019 d:000019 METHOD /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70
c:0003 p:0123 s:0009 b:0009 l:000bc8 d:000008 BLOCK  /usr/local/lib/ruby/1.9.1/webrick/server.rb:183
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP   
-- Ruby level backtrace information-----------------------------------------
config.ru:229:in `read'
config.ru:229:in `block (2 levels) in <main>'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:865:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:865:in `block in route'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `instance_eval'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `route_eval'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:500:in `block (2 levels) in route!'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `catch'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `block in route!'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `route!'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:601:in `dispatch!'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `block in call!'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `instance_eval'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `block in invoke'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `catch'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `invoke'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `call!'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:399:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/showexceptions.rb:24:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/commonlogger.rb:18:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `block in call'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:1005:in `synchronize'
/usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/lint.rb:47:in `_call'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/lint.rb:35:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/showexceptions.rb:24:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/commonlogger.rb:18:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/content_length.rb:13:in `call'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/handler/webrick.rb:48:in `service'
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

-- C level backtrace information -------------------------------------------
0x10010cd8d 0   libruby.dylib                       0x000000010010cd8d rb_vm_bugreport + 77
0x10002b184 1   libruby.dylib                       0x000000010002b184 report_bug + 260
0x10002b318 2   libruby.dylib                       0x000000010002b318 rb_bug + 200
0x1000b7124 3   libruby.dylib                       0x00000001000b7124 sigsegv + 132
0x7fff8301c80a 4   libSystem.B.dylib                   0x00007fff8301c80a _sigtramp + 26
0x1032313ac 5   libMagickCore.3.dylib               0x00000001032313ac Splay + 300
0x103119245 6   libMagickCore.3.dylib               0x0000000103119245 AcquirePixelCache + 325
0x1031cb317 7   libMagickCore.3.dylib               0x00000001031cb317 AcquireImage + 375
0x10333035b 8   libMagickCore.3.dylib               0x000000010333035b ReadPNGImage + 155
0x1031418fd 9   libMagickCore.3.dylib               0x00000001031418fd ReadImage + 2221
0x101f1b72b 10  RMagick2.bundle                     0x0000000101f1b72b rd_image + 339
0x101f1b59b 11  RMagick2.bundle                     0x0000000101f1b59b Image_read + 36
0x1000fd0e4 12  libruby.dylib                       0x00000001000fd0e4 vm_call_cfunc + 340
0x1000fe9b0 13  libruby.dylib                       0x00000001000fe9b0 vm_call_method + 896
0x1000ff8fc 14  libruby.dylib                       0x00000001000ff8fc vm_exec_core + 3180
0x100104b93 15  libruby.dylib                       0x0000000100104b93 vm_exec + 1203
0x100106643 16  libruby.dylib                       0x0000000100106643 rb_vm_invoke_proc + 691
0x100106ccd 17  libruby.dylib                       0x0000000100106ccd vm_call0 + 1085
0x1000317c6 18  libruby.dylib                       0x00000001000317c6 rb_method_call + 406
0x1000fd0e4 19  libruby.dylib                       0x00000001000fd0e4 vm_call_cfunc + 340
0x1000fe9b0 20  libruby.dylib                       0x00000001000fe9b0 vm_call_method + 896
0x1000ff8fc 21  libruby.dylib                       0x00000001000ff8fc vm_exec_core + 3180
0x100104b93 22  libruby.dylib                       0x0000000100104b93 vm_exec + 1203
0x100105ce6 23  libruby.dylib                       0x0000000100105ce6 yield_under + 710
0x100106188 24  libruby.dylib                       0x0000000100106188 specific_eval + 72
0x1000fd0e4 25  libruby.dylib                       0x00000001000fd0e4 vm_call_cfunc + 340
0x1000fe9b0 26  libruby.dylib                       0x00000001000fe9b0 vm_call_method + 896
0x1000ff8fc 27  libruby.dylib                       0x00000001000ff8fc vm_exec_core + 3180
0x100104b93 28  libruby.dylib                       0x0000000100104b93 vm_exec + 1203
0x10010b6bf 29  libruby.dylib                       0x000000010010b6bf rb_f_catch + 639
0x1000fd0e4 30  libruby.dylib                       0x00000001000fd0e4 vm_call_cfunc + 340
0x1000fe9b0 31  libruby.dylib                       0x00000001000fe9b0 vm_call_method + 896
0x1000ff8fc 32  libruby.dylib                       0x00000001000ff8fc vm_exec_core + 3180
0x100104b93 33  libruby.dylib                       0x0000000100104b93 vm_exec + 1203
0x10010aac9 34  libruby.dylib                       0x000000010010aac9 rb_yield + 505
0x100007902 35  libruby.dylib                       0x0000000100007902 rb_ary_each + 82
0x1000fd0e4 36  libruby.dylib                       0x00000001000fd0e4 vm_call_cfunc + 340
0x1000fe9b0 37  libruby.dylib                       0x00000001000fe9b0 vm_call_method + 896
0x1000ff8fc 38  libruby.dylib                       0x00000001000ff8fc vm_exec_core + 3180
0x100104b93 39  libruby.dylib                       0x0000000100104b93 vm_exec + 1203
0x100105ce6 40  libruby.dylib                       0x0000000100105ce6 yield_under + 710
0x100106188 41  libruby.dylib                       0x0000000100106188 specific_eval + 72
0x1000fd0e4 42  libruby.dylib                       0x00000001000fd0e4 vm_call_cfunc + 340
0x1000fe9b0 43  libruby.dylib                       0x00000001000fe9b0 vm_call_method + 896
0x1000ff8fc 44  libruby.dylib                       0x00000001000ff8fc vm_exec_core + 3180
0x100104b93 45  libruby.dylib                       0x0000000100104b93 vm_exec + 1203
0x10010b6bf 46  libruby.dylib                       0x000000010010b6bf rb_f_catch + 639
0x1000fd0e4 47  libruby.dylib                       0x00000001000fd0e4 vm_call_cfunc + 340
0x1000fe9b0 48  libruby.dylib                       0x00000001000fe9b0 vm_call_method + 896
0x1000ff8fc 49  libruby.dylib                       0x00000001000ff8fc vm_exec_core + 3180
0x100104b93 50  libruby.dylib                       0x0000000100104b93 vm_exec + 1203
0x100106643 51  libruby.dylib                       0x0000000100106643 rb_vm_invoke_proc + 691
0x100111803 52  libruby.dylib                       0x0000000100111803 thread_start_func_2 + 835
0x100111921 53  libruby.dylib                       0x0000000100111921 thread_start_func_1 + 17
0x7fff82ff58b6 54  libSystem.B.dylib                   0x00007fff82ff58b6 _pthread_start + 331
0x7fff82ff5769 55  libSystem.B.dylib                   0x00007fff82ff5769 thread_start + 13

You may encounter a bug of Ruby interpreter. Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap

Anyone have any idea what's going on? Thanks!

Source: (StackOverflow)

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
|-- jquery.js
`-- myapp.rb

And the following is the content of myapp.rb.

require 'rubygems'
require 'sinatra'

get "/" do
  # What should I write here to point to the `index.html`

Source: (StackOverflow)