This project is archived and is in readonly mode.

Changeset [f149eb19d4675becee164fee2881a562cdaa0551] by José Valim

January 7th, 2010 @ 02:34 PM

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.
http://github.com/rails/rails/commit/f149eb19d4675becee164fee2881a5...

Committed by José Valim

  • M actionpack/lib/action_dispatch/routing/route_set.rb
  • M actionpack/lib/action_view/helpers/url_helper.rb
  • M actionpack/test/activerecord/polymorphic_routes_test.rb
  • M actionpack/test/controller/base_test.rb

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>