0
@@ -23,7 +23,8 @@ module ActionController
0
# map.connect ':controller/:action/:id'
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
# Suppose you get an incoming request for <tt>/blog/edit/22</tt>, you'll end up
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
- # 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
+ # 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
# The following symbols are special:
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
- # ActionController::Routing::Routes.draw do |map|
0
- # map.with_options :controller => 'blog' do |blog|
0
- # blog.show '', :action => 'list'
0
- # map.connect ':controller/:action/:view'
0
+ # ActionController::Routing::Routes.draw do |map|
0
+ # map.with_options :controller => 'blog' do |blog|
0
+ # blog.show '', :action => 'list'
0
+ # map.connect ':controller/:action/:view'
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
- # ActionController::Routing:Routes.draw do |map|
0
- # map.connect ':controller/:action/:id', :controller => 'blog'
0
+ # ActionController::Routing:Routes.draw do |map|
0
+ # map.connect ':controller/:action/:id', :controller => 'blog'
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
# map.login 'login', :controller => 'accounts', :action => 'login'
0
@@ -138,22 +141,23 @@ module ActionController
0
# Routes can generate pretty URLs. For example:
0
- # map.connect 'articles/:year/:month/:day',
0
- # :controller => 'articles',
0
- # :action => 'find_by_date',
0
- # :month => /\d{1,2}/,
0
+ # map.connect 'articles/:year/:month/:day',
0
+ # :controller => 'articles',
0
+ # :action => 'find_by_date',
0
+ # :month => /\d{1,2}/,
0
+ # Using the route above, the URL "http://localhost:3000/articles/2005/11/06"
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
# == Regular Expressions and parameters
0
# You can specify a regular expression to define a format for a parameter.
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
@@ -182,7 +186,7 @@ module ActionController
0
# Specifying <tt>*[string]</tt> as part of a rule like:
0
- #
map.connect '*path' , :controller => 'blog' , :action => 'unrecognized?'
0
+ #
map.connect '*path' , :controller => 'blog' , :action => 'unrecognized?'
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
# You can reload routes if you feel you must:
0
- #
ActionController::Routing::Routes.reload
0
+ #
ActionController::Routing::Routes.reload
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
- # def test_movie_route_properly_splits
0
- # opts = {:controller => "plugin", :action => "checkout", :id => "2"}
0
- # assert_routing "plugin/checkout/2", opts
0
+ # def test_movie_route_properly_splits
0
+ # opts = {:controller => "plugin", :action => "checkout", :id => "2"}
0
+ # assert_routing "plugin/checkout/2", opts
0
# +assert_routing+ lets you test whether or not the route properly resolves into options.
0
# === +assert_recognizes+
0
- # def test_route_has_options
0
- # opts = {:controller => "plugin", :action => "show", :id => "12"}
0
- # assert_recognizes opts, "/plugins/show/12"
0
+ # def test_route_has_options
0
+ # opts = {:controller => "plugin", :action => "show", :id => "12"}
0
+ # assert_recognizes opts, "/plugins/show/12"
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
# In tests you can simply pass the URL or named route to +get+ or +post+.
0
- # assert_response :success
0
- # assert_template "jail/front"
0
+ # assert_response :success
0
+ # assert_template "jail/front"
0
# == View a list of all your routes
Comments
No one has commented yet.