Way to assign global prefix to all restful resource routes?

Hi,

I’m using the restful resource style routes in edge-rails and I’m not
trying to work the globalize-rails plugin into my app. I want to create
URLs like:

http://www.myapp.tld/en/things;new
http://www.myapp.tld/fr/things/3
etc.

… with the locale as the first thing in the URL. I’m now having to
define a :path_prefix for every resource in my routes.rb:

map.resources :units do |unit|
unit.resources :spaces,
:path_prefix => /:locale/units/:unit_id’
end

map.resources :photographables do |photographable|
photographable.resources :photo_links,
:path_prefix => /:locale/:photographable_type/:photographable_id’
end

map.resources :price_rules do |price_rule|
price_rule.resources :prices,
:path_prefix => /:locale/price_rules/:price_rule_id’
end

…and so on. A lot of repetition and a loss of DRYness having to repeat
the resource names in the prefixes. Does anyone know of a way that I
could specify a prefix globally for all routes?

Tom

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs