Question re Non Standard ID and Restful routes.

I'd like to do this..

map.resources :app, :primary_key => [:application_id]

application_id is an apple app id.

There are no relationships involved.

I thought it'd be good to do this in future

/show/:application_id

as well as / instead of

/show/:id

Thing is though, a few questions...

1) will the regular IDs still exist /show/:id / will it still be
possible to use regular IDs
2) do I have to do anything special in the migration (currently I just
create the application_id as an integer)
3) when I create a new app, will it try to get clever and auto increment
the application_id or something, I wouldn't want this - or would it
increment the regular id.

I suppose what I'm trying to say is that I'd like a route that allows me
to do /show/:application_id

Maybe I should just forget about it and use the rails id column.

Just using “map.resources :app” is enough to let you use “/show/:application_id” if you want to.

In your model, you can overwrite the to_param method to use application_id instead of id:

def to_param
application_id
end

That will cause URLs generated by URL helpers to use application_id instead of id

Then in your controller, you just need to do “App.find_by_application_id(params[:id])”

You said..

Then in your controller, you just need to do
"App.find_by_application_id(params[:id])"

did you mean.

"App.find_by_application_id(params[:application_id])"

bingo bob wrote in post #970060:

You said..

Then in your controller, you just need to do
"App.find_by_application_id(params[:id])"

did you mean.

"App.find_by_application_id(params[:application_id])"

Probably not. map.resources will always pass the parameter in as :id.

But this is why you have automated tests: so you can try it and find
out!

Best,