From 9efe01ef0d332239f37a211e2351f107de5d235b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 8 Apr 2012 23:42:02 -0300 Subject: default_url_options does not receive one argument anymore --- guides/source/action_controller_overview.textile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'guides/source/action_controller_overview.textile') diff --git a/guides/source/action_controller_overview.textile b/guides/source/action_controller_overview.textile index 52d134ace5..d6f39c486d 100644 --- a/guides/source/action_controller_overview.textile +++ b/guides/source/action_controller_overview.textile @@ -152,8 +152,7 @@ You can set global default parameters that will be used when generating URLs wit class ApplicationController < ActionController::Base - # The options parameter is the hash passed in to 'url_for' - def default_url_options(options) + def default_url_options {:locale => I18n.locale} end end -- cgit v1.2.3 From c9945b3f0a85949f8b9fa1218a868a988e6c4fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 8 Apr 2012 23:44:26 -0300 Subject: Document that default_url_options must return a hash with symbolized keys --- guides/source/action_controller_overview.textile | 1 + 1 file changed, 1 insertion(+) (limited to 'guides/source/action_controller_overview.textile') diff --git a/guides/source/action_controller_overview.textile b/guides/source/action_controller_overview.textile index d6f39c486d..a76a116103 100644 --- a/guides/source/action_controller_overview.textile +++ b/guides/source/action_controller_overview.textile @@ -152,6 +152,7 @@ You can set global default parameters that will be used when generating URLs wit class ApplicationController < ActionController::Base + # This method must return a hash with symbolized keys. def default_url_options {:locale => I18n.locale} end -- cgit v1.2.3 From 68a9788cdbd5de4c58777564aeb117b4a1866194 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 9 Apr 2012 18:26:23 +0200 Subject: rewords the section about default_url_options in the Action Controller Overview guide --- guides/source/action_controller_overview.textile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'guides/source/action_controller_overview.textile') diff --git a/guides/source/action_controller_overview.textile b/guides/source/action_controller_overview.textile index a76a116103..cc3350819b 100644 --- a/guides/source/action_controller_overview.textile +++ b/guides/source/action_controller_overview.textile @@ -148,18 +148,19 @@ In this case, when a user opens the URL +/clients/active+, +params[:status]+ wil h4. +default_url_options+ -You can set global default parameters that will be used when generating URLs with +default_url_options+. To do this, define a method with that name in your controller: +You can set global default parameters for URL generation by defining a method called +default_url_options+ in your controller. Such a method must return a hash with the desired defaults, whose keys must be symbols: class ApplicationController < ActionController::Base - # This method must return a hash with symbolized keys. def default_url_options {:locale => I18n.locale} end end -These options will be used as a starting-point when generating URLs, so it's possible they'll be overridden by +url_for+. Because 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. +These options will be used as a starting point when generating URLs, so it's possible they'll be overridden by the options passed in +url_for+ calls. + +If you define +default_url_options+ in +ApplicationController+, as in the example above, it would be used for all URL generation. The method can also be defined in one specific controller, in which case it only affects URLs generated there. h3. Session -- cgit v1.2.3