GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of lifo/doc-rails
Description: Repository for improving Rails documentation
Homepage: http://www.rubyonrails.org
Clone URL: git://github.com/zmalltalker/doc-rails.git
fixed-width font for symbols and whitespace normaliztion in AC::Routing 
docs
Xavier Noria (author)
Thu Apr 10 13:48:07 -0700 2008
commit  76632d01887448d4d5e35e16ae8f40bd18a07e64
tree    3ed36f2c6af609948afee5b5f8367f97d418257d
parent  78bd7bab32ef27d1121998f9e67ff1ad018250a0
...
23
24
25
26
 
 
27
28
29
...
36
37
38
39
40
41
42
43
 
 
 
 
 
44
45
46
...
59
60
61
62
63
64
65
66
67
 
 
 
 
 
 
68
69
70
...
75
76
77
78
79
80
 
 
 
 
81
82
83
...
93
94
95
 
96
97
98
...
138
139
140
141
142
143
144
145
146
 
 
 
 
 
 
 
 
 
147
148
149
150
 
151
152
153
154
155
156
 
 
157
158
159
...
182
183
184
185
 
186
187
188
...
210
211
212
213
 
214
215
216
...
221
222
223
224
225
226
227
 
 
 
 
228
229
230
231
232
233
234
235
236
 
 
 
 
237
238
239
...
241
242
243
244
245
246
247
248
249
250
251
252
253
 
 
 
 
 
 
 
 
 
 
254
255
256
...
23
24
25
 
26
27
28
29
30
...
37
38
39
 
 
 
 
 
40
41
42
43
44
45
46
47
...
60
61
62
 
 
 
 
 
 
63
64
65
66
67
68
69
70
71
...
76
77
78
 
 
 
79
80
81
82
83
84
85
...
95
96
97
98
99
100
101
...
141
142
143
 
 
 
 
 
 
144
145
146
147
148
149
150
151
152
153
 
 
 
154
155
156
157
158
 
 
159
160
161
162
163
...
186
187
188
 
189
190
191
192
...
214
215
216
 
217
218
219
220
...
225
226
227
 
 
 
 
228
229
230
231
232
233
234
235
236
 
 
 
 
237
238
239
240
241
242
243
...
245
246
247
 
 
 
 
 
 
 
 
 
 
248
249
250
251
252
253
254
255
256
257
258
259
260
0
@@ -23,7 +23,8 @@ module ActionController
0
   # map.connect ':controller/:action/:id'
0
   #
0
   # This route states that it expects requests to consist of a
0
- # :controller followed by an :action that in turn is fed some :id.
0
+ # <tt>:controller</tt> followed by an <tt>:action</tt> that in turn is fed
0
+ # some <tt>:id</tt>.
0
   #
0
   # Suppose you get an incoming request for <tt>/blog/edit/22</tt>, you'll end up
0
   # with:
0
@@ -36,11 +37,11 @@ module ActionController
0
   # Think of creating routes as drawing a map for your requests. The map tells
0
   # them where to go based on some predefined pattern:
0
   #
0
- # ActionController::Routing::Routes.draw do |map|
0
- # Pattern 1 tells some request to go to one place
0
- # Pattern 2 tell them to go to another
0
- # ...
0
- # end
0
+ # ActionController::Routing::Routes.draw do |map|
0
+ # Pattern 1 tells some request to go to one place
0
+ # Pattern 2 tell them to go to another
0
+ # ...
0
+ # end
0
   #
0
   # The following symbols are special:
0
   #
0
@@ -59,12 +60,12 @@ module ActionController
0
   # Within blocks, the empty pattern is at the highest priority.
0
   # In practice this works out nicely:
0
   #
0
- # ActionController::Routing::Routes.draw do |map|
0
- # map.with_options :controller => 'blog' do |blog|
0
- # blog.show '', :action => 'list'
0
- # end
0
- # map.connect ':controller/:action/:view'
0
- # end
0
+ # ActionController::Routing::Routes.draw do |map|
0
+ # map.with_options :controller => 'blog' do |blog|
0
+ # blog.show '', :action => 'list'
0
+ # end
0
+ # map.connect ':controller/:action/:view'
0
+ # end
0
   #
0
   # In this case, invoking blog controller (with an URL like '/blog/')
0
   # without parameters will activate the 'list' action by default.
0
@@ -75,9 +76,10 @@ module ActionController
0
   # Hash at the end of your mapping to set any default parameters.
0
   #
0
   # Example:
0
- # ActionController::Routing:Routes.draw do |map|
0
- # map.connect ':controller/:action/:id', :controller => 'blog'
0
- # end
0
+ #
0
+ # ActionController::Routing:Routes.draw do |map|
0
+ # map.connect ':controller/:action/:id', :controller => 'blog'
0
+ # end
0
   #
0
   # This sets up +blog+ as the default controller if no other is specified.
0
   # This means visiting '/' would invoke the blog controller.
0
@@ -93,6 +95,7 @@ module ActionController
0
   # for the full URL and +name_of_route_path+ for the URI path.
0
   #
0
   # Example:
0
+ #
0
   # # In routes.rb
0
   # map.login 'login', :controller => 'accounts', :action => 'login'
0
   #
0
@@ -138,22 +141,23 @@ module ActionController
0
   #
0
   # Routes can generate pretty URLs. For example:
0
   #
0
- # map.connect 'articles/:year/:month/:day',
0
- # :controller => 'articles',
0
- # :action => 'find_by_date',
0
- # :year => /\d{4}/,
0
- # :month => /\d{1,2}/,
0
- # :day => /\d{1,2}/
0
+ # map.connect 'articles/:year/:month/:day',
0
+ # :controller => 'articles',
0
+ # :action => 'find_by_date',
0
+ # :year => /\d{4}/,
0
+ # :month => /\d{1,2}/,
0
+ # :day => /\d{1,2}/
0
+ #
0
+ # Using the route above, the URL "http://localhost:3000/articles/2005/11/06"
0
+ # maps to
0
   #
0
- # # Using the route above, the url below maps to:
0
- # # params = {:year => '2005', :month => '11', :day => '06'}
0
- # # http://localhost:3000/articles/2005/11/06
0
+ # params = {:year => '2005', :month => '11', :day => '06'}
0
   #
0
   # == Regular Expressions and parameters
0
   # You can specify a regular expression to define a format for a parameter.
0
   #
0
- # map.geocode 'geocode/:postalcode', :controller => 'geocode',
0
- # :action => 'show', :postalcode => /\d{5}(-\d{4})?/
0
+ # map.geocode 'geocode/:postalcode', :controller => 'geocode',
0
+ # :action => 'show', :postalcode => /\d{5}(-\d{4})?/
0
   #
0
   # or, more formally:
0
   #
0
@@ -182,7 +186,7 @@ module ActionController
0
   #
0
   # Specifying <tt>*[string]</tt> as part of a rule like:
0
   #
0
- # map.connect '*path' , :controller => 'blog' , :action => 'unrecognized?'
0
+ # map.connect '*path' , :controller => 'blog' , :action => 'unrecognized?'
0
   #
0
   # will glob all remaining parts of the route that were not recognized earlier. This idiom
0
   # must appear at the end of the path. The globbed values are in <tt>params[:path]</tt> in
0
@@ -210,7 +214,7 @@ module ActionController
0
   #
0
   # You can reload routes if you feel you must:
0
   #
0
- # ActionController::Routing::Routes.reload
0
+ # ActionController::Routing::Routes.reload
0
   #
0
   # This will clear all named routes and reload routes.rb if the file has been modified from
0
   # last load. To absolutely force reloading, use +reload!+.
0
@@ -221,19 +225,19 @@ module ActionController
0
   #
0
   # === +assert_routing+
0
   #
0
- # def test_movie_route_properly_splits
0
- # opts = {:controller => "plugin", :action => "checkout", :id => "2"}
0
- # assert_routing "plugin/checkout/2", opts
0
- # end
0
+ # def test_movie_route_properly_splits
0
+ # opts = {:controller => "plugin", :action => "checkout", :id => "2"}
0
+ # assert_routing "plugin/checkout/2", opts
0
+ # end
0
   #
0
   # +assert_routing+ lets you test whether or not the route properly resolves into options.
0
   #
0
   # === +assert_recognizes+
0
   #
0
- # def test_route_has_options
0
- # opts = {:controller => "plugin", :action => "show", :id => "12"}
0
- # assert_recognizes opts, "/plugins/show/12"
0
- # end
0
+ # def test_route_has_options
0
+ # opts = {:controller => "plugin", :action => "show", :id => "12"}
0
+ # assert_recognizes opts, "/plugins/show/12"
0
+ # end
0
   #
0
   # Note the subtle difference between the two: +assert_routing+ tests that
0
   # a URL fits options while +assert_recognizes+ tests that a URL
0
@@ -241,16 +245,16 @@ module ActionController
0
   #
0
   # In tests you can simply pass the URL or named route to +get+ or +post+.
0
   #
0
- # def send_to_jail
0
- # get '/jail'
0
- # assert_response :success
0
- # assert_template "jail/front"
0
- # end
0
- #
0
- # def goes_to_login
0
- # get login_url
0
- # #...
0
- # end
0
+ # def send_to_jail
0
+ # get '/jail'
0
+ # assert_response :success
0
+ # assert_template "jail/front"
0
+ # end
0
+ #
0
+ # def goes_to_login
0
+ # get login_url
0
+ # #...
0
+ # end
0
   #
0
   # == View a list of all your routes
0
   #

Comments

    No one has commented yet.