Non-numeric IDs with RESTful routes

Hi,

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:

/countries/us/regions/ma/resources.html

instead of

/countries/8/regions/218/resources.html

I would like to use nested routes like this:

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

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

Ingo

Hi,

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)

Ingo

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