If I have a config.ru file like this:
def my_method
1+2
end
require 'my_sinatra_app'
run Sinatra::Application
Calling my_method from within my_sinatra_app.rb returns “undefined method `my_method’ for main:Object“.
As a top-level method it should be accessible from everywhere; why is my_method not accessible from within my_sinatra_app.rb?
config.ruisinstance_evaled in aRack::Builder, so the methods you define there are not in the Top level scope. If you want to have them as top level methods, you could try putting them in another file andrequireing them fromconfig.ru.ex config.ru