I have a route which routes a request to somepath/:id(.:format) to somecontroller#show.
This goes for every request in any format. However, I have one condition where somepath/:id.png should return an image, and the code for that is already implemented in othercontroller#show.
I thought it would be best to route the .png requests to othercontroller instead of duplicating the code.
What would be the way to achieve this?
I’ve considered using constraints, but I am not sure if that would be the correct approach.
The only way i see is to use
This will route all .png requests to other controller, and all other to somecontroller.
Be sure that you place png route before the other.