I am developing an API for my application.
Here is the standard show method.
@city = City.find(params[:id], :include => :state)
respond_to do |format| format.html format.xml end
For a browser based action if the params[:id] is missing then
ActiveRecord::RecordNotFound exception is raised which I let Rails
This results in public/404.html.
However in API I need to catch the exception and then I need to return
xml with the error message. What is the best way to handle that. Any
example will be helpful
Right now even if I catch the exception then after catching the
need to process two different ways for html and xml. Secondly I need to
if I am processing html or xml. How do I find out if I am handing html
xml. Is there a utility method?