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 7676415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:11:39+00:00 2026-05-31T17:11:39+00:00

require ‘sinatra/base’ class Foo < Sinatra::Base get(‘/foo’) { ‘foo’ } end class Bar <

  • 0
require 'sinatra/base'

class Foo < Sinatra::Base
  get('/foo') { 'foo' }
end

class Bar < Sinatra::Base
  get('/bar') { 'bar' }
end

run Rack::Cascade, [Foo, Bar]

I just can’t guess what is wrong with this code.
When I ran: ruby server.rb, it throws an error

  • 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-05-31T17:11:40+00:00Added an answer on May 31, 2026 at 5:11 pm

    First of all, the last line should read

    run Rack::Cascade.new [Foo, Bar]
    

    But you can only use this in a Rackup File. So second, you need to create a File called config.ru (Rackup File) with the following contents:

    require './app'
    run Rack::Cascade.new [Foo, Bar]
    

    and a file called app.rb with your actual app:

    require 'sinatra/base'
    
    class Foo < Sinatra::Base
      get('/foo') { 'foo' }
    end
    
    class Bar < Sinatra::Base
      get('/bar') { 'bar' }
    end
    

    then you can start the server by typing in the command line

    $ rackup
    >> Thin web server (v1.3.1 codename Triple Espresso)
    >> Maximum connections set to 1024
    >> Listening on 0.0.0.0:9292, CTRL+C to stop
    

    after that, open a second command line window and test your app:

    $ curl 0.0.0.0:9292/foo
    foo%
    $ curl 0.0.0.0:9292/bar
    bar%    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

require 'rubygems' require 'test/unit' class Thing attr_accessor :foo def set_stuff @foo = 'bar' end
Example: require 'commandline' class App < CommandLine::Application def initialize end def main raise 'foo'
I require nested subdirectories in my sinatra app, how can I simplify this repetitive
require 'liquid' require 'extras/liquid_view' if defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler ActionView::Template else ActionView::Base end.register_template_handler(:liquid,
require 'digest' class UserMailer < ActionMailer::Base def receive_compliment(compliment) @recipients = #{compliment.receiver.email} @from = SERVICE_EMAIL
require 'rubygems' require 'active_record' ActiveRecord::Base.establish_connection( :adapter => 'mysql2', :database => 'vft', :user => 'vft',
Possible Duplicate: PHP: Require() and Class Hierarchies Is this bad practice? Is there any
I require a tree / directed acyclic graph implementation something like this: public class
Given: require 'rubygems' require 'nokogiri' value = Nokogiri::HTML.parse(<<-HTML_END) <html> <body> <p id='para-1'>A</p> <div class='block'
I require to generate bar charts and then save them as images, in .png

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.