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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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])" -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Dec-22 17:12 UTC
Re: Question re Non Standard ID and Restful routes.
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, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.