Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Changeset [f149eb19d4675becee164fee2881a562cdaa0551] by José Valim

Revision f149eb19d4675becee164fee2881a562cdaa0551, committed 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...

4 changed files

  • 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