views:

175

answers:

1

I made my routes recognize optional path prefixes, but now I want route generation to remember them without me specifying them each time. I'm using the solution presented here:

http://stackoverflow.com/questions/212425/creating-routes-with-an-optional-path-prefix

Here are some examples:

Let's say I'm here: { path => "/", :contoller => 'welcome', :action => 'index', :locale => 'en' } then route generation works like this:

events_path #=> "/en/events"
event_path(1) #=> "/en/events/1"

This is exactly what I want, and everything's great.

Now let's consider I'm here: { path => "/fr", :contoller => 'welcome', :action => 'index', :locale => 'fr' } then route generation works like this:

events_path #=> "/en/events"
events_path(1) #=> "/en/events/1"

This is not helping me at all. What it would be natural to have is events_path to remember params[:locale] and generate "/fr/events". Is there any way I can achieve this?

A: 

Unless I'm misunderstanding what you're saying the desired behaviour is exactly the one I've written routing_filter for :)

Try using the provided locale filter by installing the plugin and simply adding map.filter(:locale) to your routes.

If that does not help, please email me or send me a message on github.