mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
use url helper for redirects in README
This commit is contained in:
parent
c835bdd78e
commit
da9bfdeabc
1 changed files with 5 additions and 5 deletions
10
README.rdoc
10
README.rdoc
|
@ -794,17 +794,17 @@ Similar to the body, you can also set the status code:
|
|||
You can trigger a browser redirect with the `redirect` helper method:
|
||||
|
||||
get '/foo' do
|
||||
redirect '/bar'
|
||||
redirect to('/bar')
|
||||
end
|
||||
|
||||
Any additional parameters are handled like arguments passed to `halt`:
|
||||
|
||||
redirect '/bar', 303
|
||||
redirect '/bar', 'wrong place, buddy'
|
||||
redirect to('/bar'), 303
|
||||
redirect 'http://google.com', 'wrong place, buddy'
|
||||
|
||||
To pass arguments with a redirect, either add them to the query:
|
||||
|
||||
redirect '/bar?sum=42'
|
||||
redirect to('/bar?sum=42')
|
||||
|
||||
Or use a session:
|
||||
|
||||
|
@ -812,7 +812,7 @@ Or use a session:
|
|||
|
||||
get '/foo' do
|
||||
session[:secret] = 'foo'
|
||||
redirect '/bar'
|
||||
redirect to('/bar')
|
||||
end
|
||||
|
||||
get '/bar' do
|
||||
|
|
Loading…
Reference in a new issue