The problem is that the error_404
method inside the Default
controller can't handle requests in png format. When you ask for say, a JSON response, you could build an URL similar to:
/controller/action.json
And inside the action you would have something like
def action
respond_to do |format|
format.html # Renders the default view
format.json { render :json => @model }
format.xml { render :xml => @model }
end
end
As you can see, it's specified how to handle a JSON and an XML request, but since there's no format.png
, the action can't handle the .png
format. Add this:
format.png # Handle the request here...
Hope it helps :)
Edit
Add this to redirect to your 404 handler:
def error_404
respond_to do |format|
format.html
format.png { redirect_to :controller => 'default', :action => 'error_404' }
end
end
Cheers :)
Edit2
Use this code to catch all kinds of requests:
def error_404
respond_to do |format|
format.html { render :not_found_view }
format.all { redirect_to controller: 'default', action: 'error_404' }
end
end
Replace :not_found_view
with your 404 page. This will render the 404 page for html requests, and redirect to self (with html format) for any other kind of request.
Hope it helps :)