Filtering routes based on format


We've had some requests though for nonsense URLs which have slipped
through to our controllers and caused ActionView::MissingTemplate
exceptions. They're from URLs like


I feel like it should be possible to block this request at the routing
stage - before it reaches the artists controller, but I can't see how
it could be done. We use restful routes, so the artists controller is
wired up using

    map.resources :artists

Is there any way to add an option to this call to specify the formats
that are acceptable (and thus return a 40x code if the format is not
in the whitelist?)


    map.resources :artists, :format => [ :html, :json ]

I can't see anything in the docs, or indeed the code, which would let
me do this, but I might well have missed something.


For routing information you could read here:

I'm guessing you could use regular expressions or something else to
reduce the actions that could be called on a given controller.

Another thing you could do is use method_missing and redirect to an
error page, I guess.