How do you debug a Sinatra app like a Rails app?
You could try adding a before filter that prints out the parameters
before do
puts '[Params]'
p params
end
My opinion is that for debug you should use configure :development
do because some debugging flags are turned on in this scenario. So, under your configure do
block you can enable the flags:
enable :logging, :dump_errors, :raise_errors
and for your logging facility:
log = File.new("sinatra.log", "a")
STDOUT.reopen(log)
STDERR.reopen(log)
From the Sinatra handbook:
dump_errors
option controls whether the backtrace is dumped torack.errors
when an exception is raised from a route. The option is enabled by default for top-level apps.raise_errors
- allow exceptions to propagate outside of the app (...) The:raise_errors
option is disabled by default for classic style apps and enabled by default for Sinatra::Base subclasses.
I also use the
puts "something" + myvar.inspect
method in the middle of my controllers.