scoped parameter is not correctly parsed in named_routes

13 views
Skip to first unread message

Stijnster

unread,
Sep 10, 2010, 6:27:35 AM9/10/10
to I18n Routing
Hi there,

first of all thanks for the updated plugin. Its great to see that the
plugin is nicely moving along with the framework. With this new
release however, I have a small problem which wasn't a problem before.

I have a routes file defined like this;

localized(Twizzi::SUPPORTED_LOCALES) do
scope '/:locale', :constraints => { :locale => /[a-z]{2}/ } do

match '/' => "dashboards#index", :as => :localized_root
match '/login' => 'user_sessions#new', :as => :login
match '/logout' => 'user_sessions#destroy', :as => :logout

resources :admins

# more routes defined
end
end

The scope is being used to detect the locale that the user selects.
However, when I run the

localized_root_path(:locale => 'fr')

the generated routes become;

/?locale=fr
/login/?locale=fr
/logout/?locale=fr

instead of

/fr
/fr/login
/fr/logout

The resources however are generated correctly, so it appears to be
only in named routes.

I have a method in my application_controller.rb that sets the default
parameters like this;

# Sets the default URL options.
def default_url_options(options={})
{ :locale => I18n.locale }
end


Does anyone have an idea what the problem might be?


Best regards,

Stijn

Stijnster

unread,
Sep 10, 2010, 10:32:27 AM9/10/10
to I18n Routing
After a while, debugging the plugin code, I found out that there is
also a localized_ method for each named route.

When I use that localized_login_path with a given :locale => 'nl', or
with the default_url_options method it all seems to work well!

Is it meant to work this way, or should the original login_path also
work as described above?

Regards,

Stijn

Guillaume Luccisano

unread,
Sep 10, 2010, 10:49:56 AM9/10/10
to i18n-r...@googlegroups.com
Hi Stijn,

No, the plugin should works totally transparently, so the original login_path should works.
This looks like to be a bug in the last version, I will check this out soon.
I keep you posted.

Thanks for using the gem by the way:)

Guillaume

2010/9/10 Stijnster <s.mat...@telenet.be>

Guillaume Luccisano

unread,
Sep 11, 2010, 1:58:58 PM9/11/10
to i18n-r...@googlegroups.com
Hi again Stijn,

I have just released the 0.4.1 version of i18n_routing that should fix your bug !
Tell me if everything is ok now.

Thanks,
Guillaume

2010/9/10 Guillaume Luccisano <guillaume...@gmail.com>
Reply all
Reply to author
Forward
0 new messages