aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides/source/actioncontroller_basics/params.txt
diff options
context:
space:
mode:
authorTore Darell <toredarell@gmail.com>2008-11-05 00:13:24 +0100
committerTore Darell <toredarell@gmail.com>2008-11-05 00:13:24 +0100
commitce66cc642aa9cbc8b162c8e02999259c87b640bb (patch)
tree8ce0bb717fc968c69901acd6ebbba6a275fbb0fe /railties/doc/guides/source/actioncontroller_basics/params.txt
parent6e48cd202cae0f5fc7419d368e70070aa35b0fc5 (diff)
downloadrails-ce66cc642aa9cbc8b162c8e02999259c87b640bb.tar.gz
rails-ce66cc642aa9cbc8b162c8e02999259c87b640bb.tar.bz2
rails-ce66cc642aa9cbc8b162c8e02999259c87b640bb.zip
Add example of using default_url_options
Diffstat (limited to 'railties/doc/guides/source/actioncontroller_basics/params.txt')
-rw-r--r--railties/doc/guides/source/actioncontroller_basics/params.txt17
1 files changed, 17 insertions, 0 deletions
diff --git a/railties/doc/guides/source/actioncontroller_basics/params.txt b/railties/doc/guides/source/actioncontroller_basics/params.txt
index 7f494d7c9b..4c071a0ab3 100644
--- a/railties/doc/guides/source/actioncontroller_basics/params.txt
+++ b/railties/doc/guides/source/actioncontroller_basics/params.txt
@@ -60,3 +60,20 @@ 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.
+
+=== `default_url_options` ===
+
+You can set global default parameters that will be used when generating URLs with `default_url_options`. To do this, define the method in your controller:
+
+------------------------------------
+class ApplicationController < ActionController::Base
+
+ #The options parameter is the hash passed in to url_for
+ def default_url_options(options)
+ {:locale => I18n.locale}
+ end
+
+end
+------------------------------------
+
+These options will be used as a starting-point when generating, so it's possible they'll be overridden by url_for. As this method is defined in the controller, you can define it on ApplicationController so it would be used for all URL generation, or you could define it on only one controller for all URLs generated there.