How to handle bad formats in routes in Rails 2.3? For example, suppose you have an action that wants to handle html or json requests, but nothing else, how do you limit it to let the user read the errors public? The following snippet shows the beginning:
respond_to do |format|
format.html
format.json { do something appropriate }
format.all ?
end
The problem is, what to put in place of "?", I tried:
format.all :text => "That a bad format.", :status => 406
and while the status code has been set appropriately, the text will not be displayed (at least with a format like com that I get.
One possibility would be to change the route file so that only two formats are accepted, but this led to an explosion of the route. (I have 4 acceptable formats.) The idea of using
map.connect '/xyz.:format', :action => ..., :controller => ..., :format => '/html|json/'
, - - xyz.comhtml. , - .