I have a silverlight application that needs to talk to a rails app to add a record. I have been able to get the silverlight app to successfully do the POST assuming everything goes good. Now, however, I need to be able to make it more robust and have the rails app return error/success messages to the silverlight app in a format it can read (xml maybe?). I can modify the rails app and silverlight app as needed.
What is the best way to accomplish this with rails?
Rails handles most of this out-of-the-box.
You need to have a look at respond_to
This will return the records in @list as XML:
You can set status using http headers (for actions that don’t return anything):
And you can provide more complex messages, in this case returning Active Record errors and a status message: