What is the difference between using redirect
and redirect to
in Sinatra? They both seem to default to the same status code. Is the to '/url'
bit just some syntactic niceness to make the method more readable?
The redirect
method sends the HTTP header to redirect the client to a given URL, and the argument passed should be a fully qualified URL with a host (e.g. http://example.com/path
, not just /path
).
The to
method converts a path to a full URL for your Sinatra app, allowing the resulting URL to be used in redirect
. E.g. to('/path')
would become http://yoursinatraapp/path
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With