I have an app and it runs fine if I do rackup or puma but it doesn't run when I do ruby app.rb I tried puttingrequire 'sinatra'run Sinatra::Application on the bottom but it says run is not defined.
# app.rb
class MyApp < Sinatra::Application
get '/' do
'Hello, world!'
end
run! if $0 == __FILE__
end
If you're writing an app in classic mode, you don't need to run it at the bottom of the file; it runs automatically if invoked directly (i.e. ruby app.rb). If you're writing an app in modular mode, you can put a run! at the bottom of the class to run it automatically if it's invoked directly:
I have it in the classic mode but for some reason it doesn't run when I invoke it that way.