Ruby on rails 如何在Rails 3.2中为所有未知请求(包括图像)呈现相同的404页面,而不单独指定每个文件格式?

Ruby on rails 如何在Rails 3.2中为所有未知请求(包括图像)呈现相同的404页面,而不单独指定每个文件格式?,ruby-on-rails,ruby-on-rails-3.2,routes,actionview,Ruby On Rails,Ruby On Rails 3.2,Routes,Actionview,对于404s,我们在routes.rb中使用以下“捕获所有路由”: # Catches all 404 errors and redirects match '*url' => 'default#error_404' 但这会在下面生成一个500内部服务器错误,因为我们没有在error_404中专门捕获PNG格式 Started GET "/images/doesnotexistyo.png" for 71.198.44.101 at 2013-03-08 07:59:24 +0300 P

对于404s,我们在routes.rb中使用以下“捕获所有路由”:

# Catches all 404 errors and redirects
match '*url' => 'default#error_404'
但这会在下面生成一个500内部服务器错误,因为我们没有在error_404中专门捕获PNG格式

Started GET "/images/doesnotexistyo.png" for 71.198.44.101 at 2013-03-08 07:59:24 +0300
Processing by DefaultController#error_404 as PNG
  Parameters: {"url"=>"images/doesnotexistyo"}
Completed 500 Internal Server Error in 1ms

ActionView::MissingTemplate (Missing template default/error_404, application/error_404 with {:locale=>[:en], :formats=>[:png], :handlers=>[:erb, :builder]}. Searched in:
  * "/home/prod/Prod/app/views"

理想情况下,所有未知请求都会呈现默认的#error_404 HTML操作。我们不知道如何获得格式。任何来呈现404 HTML操作。如何使用错误404 HTML响应呈现所有未知请求?

在应用程序控制器中:

从“ActionController::UnknownAction”中营救:with=>:render_404
将_从“ActionController::RoutingError”中解救出来:with=>:render_404
def渲染器404
回应待办事项|格式|
format.html{render:template=>“”,:status=>404}
format.xml{head 404}
format.js{head 404}
format.json{head 404}
结束
返回错误
结束

return false有什么作用?我也看不出return false有什么原因。
rescue_from "ActionController::UnknownAction", :with => :render_404
rescue_from "ActionController::RoutingError",  :with => :render_404

def render_404
  respond_to do |format|
    format.html { render :template => "<PATH_OF_404_ERROR_TEMPLATE>", :status => 404 }       
    format.xml { head 404 }
    format.js { head 404 }
    format.json { head 404 }
  end
  return false
end