The code faces several constraints:
??? Path segments may capture multiple parts of the URL:
??” Controllers may be namespaced, so the route ":controller/:action/:id"
can match the URL "/store/product/edit/15", with the controller being
"store/product".
??” Routes may contain path_info segments that destructure multiple URL segments:
the route "page/*path_info" can match the URL "/page/products/
top_products/15", with the path_info segment capturing the remainder of
the URL.
??? Routes can be restricted by conditions that must be met in order for the route to
match.
??? The routing system must be bidirectional; it is run forward to recognize routes
and in reverse to generate them.
??? Route recognition must be fast because it is run once per HTTPrequest. Route
generation must be lightning fast because it may be run tens of times per HTTP
request (once per outgoing link) when generating a page.
Michael Koziarski??™s new routing_optimisation code in Rails 2.0
(actionpack/lib/action_controller/routing_optimisation.rb) addresses the
complexity of Rails routing. This new code optimizes the simple case
of generation of named routes with no extra :requirements.
44 | Chapter 1: Foundational Techniques
Because of the speed needed in both generation and recognition, the routing code
modifies itself at runtime. The ActionController::Routing::Route class represents a
single route (one entry in config/routes.
Pages:
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78