diff options
author | Tore Darell <toredarell@gmail.com> | 2008-11-05 00:25:31 +0100 |
---|---|---|
committer | Tore Darell <toredarell@gmail.com> | 2008-11-05 00:25:31 +0100 |
commit | b8a9c4fa29c8fff903ac5c7d70b2321cabddde87 (patch) | |
tree | 3aaf22302e1ead52d9ebcc374bbb3028cb376cbf | |
parent | 9d08df5bd8071db346b871e69ad76a59cc0f6430 (diff) | |
download | rails-b8a9c4fa29c8fff903ac5c7d70b2321cabddde87.tar.gz rails-b8a9c4fa29c8fff903ac5c7d70b2321cabddde87.tar.bz2 rails-b8a9c4fa29c8fff903ac5c7d70b2321cabddde87.zip |
Add example using routing parameters
-rw-r--r-- | railties/doc/guides/source/actioncontroller_basics/params.txt | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/railties/doc/guides/source/actioncontroller_basics/params.txt b/railties/doc/guides/source/actioncontroller_basics/params.txt index 4c071a0ab3..4b9bea7777 100644 --- a/railties/doc/guides/source/actioncontroller_basics/params.txt +++ b/railties/doc/guides/source/actioncontroller_basics/params.txt @@ -59,7 +59,16 @@ The value of `params[:client]` when this form is submitted will be `{:name => " === Routing parameters === -The `params` hash will always contain the `:controller` and `:action` keys, but you should use the methods `controller_name` and `action_name` instead to access these values. Any other parameters defined by the routing, such as `:id` will also be available. +The `params` hash will always contain the `:controller` and `:action` keys, but you should use the methods `controller_name` and `action_name` instead to access these values. Any other parameters defined by the routing, such as `:id` will also be available. As an example, consider a listing of clients where the list can show either active or inactive clients. We can add a route which captures the `:status` parameter in a "pretty" URL: + +[source, ruby] +------------------------------------ +# ... +map.connect "/clients/:status", :controller => "clients", :action => "index", :foo => "bar" +# ... +------------------------------------ + +In this case, when a user opens the URL `/clients/active`, `params[:status]` will be set to "active". When this route is used, `params[:foo]` will also be set to "bar" just like it was passed in the query string in the same way `params[:action]` will contain "index". === `default_url_options` === |