Skip to content

Instantly share code, notes, and snippets.

@lukesutton
Created November 11, 2008 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukesutton/24027 to your computer and use it in GitHub Desktop.
Save lukesutton/24027 to your computer and use it in GitHub Desktop.
The idea is to be able to examine a path inside a #defer_to block and
optionally rewrite parts of the request — path, subdomain etc. After the
rewrite, the request will go through the router again, where any matching
routes will then pick it up.
match("/:locale/:dialect/:full_path", :full_path => /\S+/).defer_to do |request, params|
if is_clever? params[:full_path]
rewrite(params, :subdomain => "admin", :path => "/bongst")
else
params
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment