Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8640957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:24:15+00:00 2026-06-12T11:24:15+00:00

When I run ruby filename.rb , the thin webserver startsup but when I try

  • 0

When I run ruby filename.rb, the thin webserver startsup but when I try to view the (Sinatra) application on localhost:4567 I’m getting this error message. Googling it revealed nothing. Does anyone know what I might do to get past this?

gems/eventmachine-0.12.10/lib/em/connection.rb:39:in `block in new': undefined method `associate_callback_target' for #<Thin::Connection:0x00000100fc7500> (NoMethodError)
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/em/connection.rb:36:in `instance_eval'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/em/connection.rb:36:in `new'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/eventmachine.rb:1430:in `event_callback'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/pr_eventmachine.rb:815:in `block in eventable_read'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/pr_eventmachine.rb:812:in `times'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/pr_eventmachine.rb:812:in `eventable_read'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/pr_eventmachine.rb:369:in `block in crank_selectables'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/pr_eventmachine.rb:369:in `each'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/pr_eventmachine.rb:369:in `crank_selectables'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/pr_eventmachine.rb:324:in `block in run'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/pr_eventmachine.rb:318:in `loop'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/pr_eventmachine.rb:318:in `run'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/pr_eventmachine.rb:64:in `run_machine'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/thin-1.4.1/lib/thin/backends/base.rb:63:in `start'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/thin-1.4.1/lib/thin/server.rb:159:in `start'
    from /Users/mm/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
    from /Users/mm/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/sinatra-1.3.3/lib/sinatra/base.rb:1350:in `run!'
    from /Users/mm/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/sinatra-1.3.3/lib/sinatra/main.rb:25:in `block in <module:Sinatra>'

The code is from a book Cloning Internet Applications in Ruby. It’s happening with each of its demo applications…

Route code

get '/' do haml :index end

post '/' do
  uri = URI::parse(params[:original])
  custom = params[:custom].empty? ? nil : params[:custom]
  raise "Invalid URL" unless uri.kind_of? URI::HTTP or uri.kind_of? URI::HTTPS
  @link = Link.shorten(params[:original], custom) 
  haml :index
end

['/info/:short_url', '/info/:short_url/:num_of_days', '/info/:short_url/:num_of_days/:map'].each do |path|
  get path do
    @link = Link.first(:identifier => params[:short_url])
    raise 'This link is not defined yet' unless @link
    @num_of_days = (params[:num_of_days] || 15).to_i
    @count_days_bar = Visit.count_days_bar(params[:short_url], @num_of_days)
    chart = Visit.count_country_chart(params[:short_url], params[:map] || 'world')
    @count_country_map = chart[:map]
    @count_country_bar = chart[:bar]
    haml :info
  end
end

get '/:short_url' do 
  link = Link.first(:identifier => params[:short_url])
  link.visits << Visit.create(:ip => get_remote_ip(env))
  link.save
  redirect link.url.original, 301
end

error do haml :index end

def get_remote_ip(env)
  if addr = env['HTTP_X_FORWARDED_FOR']
    addr.split(',').first.strip
  else
    env['REMOTE_ADDR']
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:24:16+00:00Added an answer on June 12, 2026 at 11:24 am

    I’m the author of the Cloning Internet Applications with Ruby book. I tried running the code in the GitHub repository, and barring for a few changes (due to changes in Sinatra) I can run it successfully. Perhaps you can try the answer given by Prakash Murthy, to upgrade to EventMachine 1.0.0 but I’m running the same version as you are (0.12.10) and that doesn’t give me any problems.

    If you drop me an email directly we can figure this out (and update Stack Overflow later).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On windows, I can run my ruby script like this: > ruby myscript.rb but
I tried to run ruby script/server RAILS_ENV=production but somehow it always try to read
I'm doing an online-judge application and I wish to run a ruby script (or
I'm learning Ruby (using version 1.8.6) on Windows 7. When I try to run
Maybe I'm missing something simple here, but when I run ruby script/server, I can
I am having a problem getting a Ruby script to work correctly when run
Possible Duplicate: Can't run a ruby hello world application in Aptana I've just installed
The SciTE editor will run Ruby programs for me if I press F5. But
I want to make notepad++ run the ruby {filename_here} command if the current filename
I want to make apache2 run ruby scripts. I managed to do this by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.