diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-07 15:26:31 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-07 15:34:14 +0100 |
commit | f149eb19d4675becee164fee2881a562cdaa0551 (patch) | |
tree | fd72fc45c5a319ec37687e19266d06b7de509682 /rails.gemspec | |
parent | f564f947d94645dca8ff67fc5c2ad161eb2bb187 (diff) | |
download | rails-f149eb19d4675becee164fee2881a562cdaa0551.tar.gz rails-f149eb19d4675becee164fee2881a562cdaa0551.tar.bz2 rails-f149eb19d4675becee164fee2881a562cdaa0551.zip |
From now on, parameters defined in default_url_options can be absent from named routes.
This allows the following setup to work:
# app/controllers/application_controller.rb
class ApplicationController
def default_url_options(options=nil)
{ :locale => I18n.locale }
end
end
# From your views and controllers:
I18n.locale #=> :en
users_url #=> "/en/users"
users_url(:pl) #=> "/pl/users"
user_url(1) #=> "/en/users/1"
user_url(:pl, 1) #=> "/pl/users/1"
user_url(1, :locale => :pl) #=> "/pl/users/1"
If you provide all expected parameters, it still works as previously.
But if any parameter is missing, it tries to assign all possible ones
with the hash returned in default_url_options or the one passed straight
to the named route method.
Beware that default_url_options in ApplicationController is not shared
with ActionMailer, so you are required to always give the locale in your
email views.
Diffstat (limited to 'rails.gemspec')
0 files changed, 0 insertions, 0 deletions