Non-numeric IDs with RESTful routes


I think I do understand why (the core team feels that) REST resource
URLs should use numeric IDs, like for example because human-readable IDs
might change and cause URLs to break. However, I am wondering whether
most of these reasons really apply for identifiers that are agreed-upon
standards, such as country codes. In my case, I am working with regional
resources that I think should use the following format:


instead of


I would like to use nested routes like this:

map.resources :countries do |country|
country.resources :regions do |region|
regions.resources :resources

How can this be done? I tried the resource_hacks plugin, but couldn’t
get the above to work.



I should be more clear about this: Models should keep their integer IDs,
but for the URLs another identifier should be used, maybe one that is
unique only in the scope of the parent resource (There could be another
‘ma’ region in another country)


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