Best way to create a route that only accepts one format

Hey guys,

I haven’t done this before so I thought I’d ping the mailing list to see
if anyone has any better ideas than what I’ve come up with.

I want to create a route that looks something like this:

url.com/counter/:id.png

Basically, this will route to the “show” method in the controller, and
should only work if the format requested is .png.

I’m using this controller for other things as well, but any other time
it’s accessed through a nested route:

url.com/users/1/ads/:id

So here’s what I’ve come up with:

map.resources :ads, :only => :show, :as => :counter, :requirements =>
{ :format => :png }
map.resources :users, :has_many => :ads

This seems to be working, however instead of a 404 Not Found being
returned to the browser, it’s returning a 406 Not Acceptable.

Is there any way to generate this route so that unless the format is png
it will return the usual 404 Not Found when a route doesn’t exist?

Thanks,
Josh