aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/i18n.md
diff options
context:
space:
mode:
authorNikolay Shebanov <nikolay.shebanov@gmail.com>2014-04-02 13:12:52 +0400
committerNikolay Shebanov <nikolay.shebanov@gmail.com>2014-04-03 05:46:44 +0400
commit3f70c69437531e975838d1788b13570972453113 (patch)
treeac02f2aac7ecfff594da2e62d213763d47e144d7 /guides/source/i18n.md
parentdef60710ad74132a322fe8a08b0a6f0bbd3a3eed (diff)
downloadrails-3f70c69437531e975838d1788b13570972453113.tar.gz
rails-3f70c69437531e975838d1788b13570972453113.tar.bz2
rails-3f70c69437531e975838d1788b13570972453113.zip
Fix default_url_options example in i18n guide [ci skip]
Diffstat (limited to 'guides/source/i18n.md')
-rw-r--r--guides/source/i18n.md9
1 files changed, 4 insertions, 5 deletions
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index bef738b75b..6bd033f0de 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -212,17 +212,16 @@ The most usual way of setting (and passing) the locale would be to include it in
This approach has almost the same set of advantages as setting the locale from the domain name: namely that it's RESTful and in accord with the rest of the World Wide Web. It does require a little bit more work to implement, though.
-Getting the locale from `params` and setting it accordingly is not hard; including it in every URL and thus **passing it through the requests** is. To include an explicit option in every URL (e.g. `link_to( books_url(locale: I18n.locale))`) would be tedious and probably impossible, of course.
+Getting the locale from `params` and setting it accordingly is not hard; including it in every URL and thus **passing it through the requests** is. To include an explicit option in every URL, e.g. `link_to(books_url(locale: I18n.locale))`, would be tedious and probably impossible, of course.
-Rails contains infrastructure for "centralizing dynamic decisions about the URLs" in its [`ApplicationController#default_url_options`](http://api.rubyonrails.org/classes/ActionController/Base.html#M000515), which is useful precisely in this scenario: it enables us to set "defaults" for [`url_for`](http://api.rubyonrails.org/classes/ActionController/Base.html#M000503) and helper methods dependent on it (by implementing/overriding this method).
+Rails contains infrastructure for "centralizing dynamic decisions about the URLs" in its [`ApplicationController#default_url_options`](http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Base.html#method-i-default_url_options), which is useful precisely in this scenario: it enables us to set "defaults" for [`url_for`](http://api.rubyonrails.org/classes/ActionDispatch/Routing/UrlFor.html#method-i-url_for) and helper methods dependent on it (by implementing/overriding this method).
We can include something like this in our `ApplicationController` then:
```ruby
# app/controllers/application_controller.rb
-def default_url_options(options={})
- logger.debug "default_url_options is passed options: #{options.inspect}\n"
- { locale: I18n.locale }
+def default_url_options(options = {})
+ { locale: I18n.locale }.merge options
end
```