Redirecting
To perform a client side redirect in Mack is quite simple:
class UsersController
include Mack::Controller
def refer_me
redirect_to('/some/other/url')
end
end
When a request comes into UsersController#refer_me it will be redirected to '/some/other/url'. Because this is a client side redirect the response is sent down to the client and the client will then make another request to the new url. This also means that the url will change from the original url to the new url.
You can also pass in a :status option to change the HTTP status code for the request.
Mack is also capable of performing server side redirects. The benefit here is that client is not aware that the url has changed:
class UsersController
include Mack::Controller
def refer_me
redirect_to('/some/other/url', :server_side => true)
end
end