I’ve implemented an iPhone App that uses a RESTful HTTP POST to register itself with a web server via Rails.
Some time later, the App needs to update its own record on the server, and so needs to know the id of its own record for the RESTful HTTP PUT path.
However, the App was never told the id of its own record on the web server resulting from the POST. So, it then needs to search for it on the server using the device’s UDID (stored in the record), return the corresponding id, and then construct a RESTful URL based on that… this all seems rather cumbersome.
Is there a more elegant design-pattern for this? (it would be convenient if the original POST returned some data that allowed me to obtain the record id, but it doesn’t seem to).
Thanks.
To close this question off, the answer, which was supplied by Oscar Del Ben above, is that it is indeed necessary to find the record using some other unique key e.g. UDID, and update that record with a POST once retrieved.
(of course, the POST also returns the created record, with id, so it could be saved that way, if the design allows)