A usual usage of respond_to is like
respond_to do |format|
format.html
format.xml { render :xml => @data }
end
can it be made so that when the format is not supported (such as json or csv not being supported above), instead of returning nothing, return a text line saying “the format is not supported”, or better yet, have it automatically report “only html and xml is supported”? It can know only html and xml are supported by the existing format.html and format.xml lines there. (if possible)
You should be able to use
format.allIf you want to list the supported formats you’ll need to extend the Responder class.
Put this in something like config/initializers/extend_responder.rb
Then use this in your controller: