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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:58:39+00:00 2026-06-02T16:58:39+00:00

I am perplexed by something that isn’t actually a practical problem – just a

  • 0

I am perplexed by something that isn’t actually a practical problem – just a conceptual conundrum – about deploying a Sinatra app on Heroku.

I have two apps, identical in just about every respect, except that one puts most of its logic in a file that does not contain the Sinatra::Base class and uses a ‘require otherfilename’ to pick up the logic it needs. That Sinatra:Base class is named Kincalc.

For the app with all the logic in one file (that is, the same file that contains the Sinatra:Base class), in my config.ru file, the last line reads “run Sinatra::Application” and it launches fine. But in the other app, if I include that as the last line, the app uploads properly and says it was “deployed to Heroku” but it brings up a “Not found” message. When I have the last line read ‘run Kincalc’, it loads fine.

I have checked this back and forth and there is nothing different about how these two apps are built, except for the fact that one uses a second file for the logic (which is also at root). Why should this be a problem, or is this really the problem? When I try to put the second file (the one without the Sinatra class) in a separate lib folder, it still works when I call the class name but not when I call “Sinatra::Application.”

  • 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-02T16:58:41+00:00Added an answer on June 2, 2026 at 4:58 pm

    Code at top level will be delegated to Sinatra::Application, so this would be a scenario for running a classic application:

    # app.rb
    require 'sinatra'
    
    get '/' do
      'hi'
    end
    
    # config.ru
    require './app'
    run Sinatra::Application
    

    If you define a modular app, you would run it like this:

    # app.rb
    require 'sinatra/base'
    
    class Kincalc < Sinatra::Base
      get '/' do
        'hi'
      end
    end
    
    # config.ru
    require './app'
    run Kincalc
    

    Now I assume what you are trying to do is this:

    # otherfilename.rb
    require 'sinatra'
    
    get '/' do
      'hi'
    end
    
    # app.rb
    require 'sinatra/base'
    
    class Kincalc < Sinatra::Base
      require './otherfilename'
    end
    
    # config.ru
    require './app'
    run Kincalc # Sinatra::Application seems to work
    

    The behavior you experience (getting a 404 File Not Found) is actually correct, as require does not care about the lexical scope it is called in. Check out the following example

    # a.rb
    puts "in a, top level: #{self.inspect}"
    
    module Example
      puts "in a, nested: #{self.inspect}"
      require 'b'
    end
    
    # b.rb
    puts "in b: #{self.inspect}"
    

    The resulting output should be:

    in a, top level: main
    in a, nested: Example
    in b: main
    

    So, if you want to use one modular application, you should do something like this:

    # otherfilename.rb
    Kincalc.get '/' do
      'hi'
    end
    

    Or open the class again:

    # otherfilename.rb
    class Kincalc
      get '/' do
        'hi'
      end
    end
    

    Or you could actually have otherfilename.rb make it’s definitions on Sinatra::Application and utilize that in Kincalc.

    # app.rb
    require 'sinatra/base'
    require './otherfilename'
    
    class Kincalc < Sinatra::Base
      use Sinatra::Application
    end
    

    Or you could change where top level DSL methods are delegated to:

    # app.rb
    require 'sinatra/base'
    
    class Kincalc < Sinatra::Base
      Sinatra::Delegator.target = self
      require './otherfilename'
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've looked through similar questions but I'm still a little perplexed about something that
I have an iPhone localization problem that has me perplexed. I was localizing my
Being a bit perplexed about this issue by now, I hope some of you
i'm not sure about something. when i use critical_section/mutex/semaphor in c++ for example ,
I'm perplexed by this. I have a login action that looks like this: public
This is a strange problem but I am perplexed on how to solve this
I have a asp.net page I'm writing and I'm perplexed by this problem. I
I'm perplexed. At CodeRage today, Marco Cantu said that CharInSet was slow and I
So, this one has me a little perplexed. I'm probably just looking at it
I have an issue that has me completely perplexed. I built a simple openGL

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.