public
Description: Repository for improving Rails documentation
Homepage: http://www.rubyonrails.org
Clone URL: git://github.com/lifo/doc-rails.git
Search Repo:
added an example for resources :requirements option, closes 
http://rails.lighthouseapp.com/projects/8994/tickets/15
Xavier Noria (author)
Tue Apr 22 23:43:32 -0700 2008
commit  0e599c4bae7d9339855c395e6611632bd5f6d3a3
tree    6b32100ec711254156e89a7dc099ffd32e61beec
parent  9078b3f9bf2a5e0b41162d4b09e65b505e88cf6d
...
240
241
242
243
 
 
 
 
 
 
 
244
245
 
246
247
248
249
250
 
251
252
253
...
240
241
242
 
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
0
@@ -240,14 +240,22 @@
0
     # * <tt>:new</tt> - Same as <tt>:collection</tt>, but for actions that operate on the new resource action.
0
     # * <tt>:controller</tt> - Specify the controller name for the routes.
0
     # * <tt>:singular</tt> - Specify the singular name used in the member routes.
0
- # * <tt>:requirements</tt> - Set custom routing parameter requirements.
0
+ # * <tt>:requirements</tt> - Set custom routing parameter requirements. For example:
0
+ #
0
+ # # GET /products/001 => { :controller => 'products', :action => 'show', :id => '001' }
0
+ # # GET /products/1 => RoutingError
0
+ # # GET /products/1234 => RoutingError
0
+ # map.resources :products, :requirements => { :id => /\d\d\d/ }
0
+ #
0
     # * <tt>:conditions</tt> - Specify custom routing recognition conditions. Resources sets the <tt>:method</tt> value for the method-specific routes.
0
     # * <tt>:as</tt> - Specify a different resource name to use in the URL path. For example:
0
+ #
0
     # # products_path == '/productos'
0
     # map.resources :products, :as => 'productos' do |product|
0
     # # product_reviews_path(product) == '/productos/1234/comentarios'
0
     # product.resources :product_reviews, :as => 'comentarios'
0
     # end
0
+ #
0
     # Note that the name of the path generator method is still based on the original resource name.
0
     # * <tt>:has_one</tt> - Specify nested resources, this is a shorthand for mapping singleton resources beneath the current.
0
     # * <tt>:has_many</tt> - Same has <tt>:has_one</tt>, but for plural resources.

Comments

    No one has commented yet.