我正在使用 exception_handler gem 来制作自定义 404 页面。当我转到我网站上的 404 页面时,它显示未找到,但如何自定义此页面?我尝试更改路线,制作 errors_controller 和 not_found 视图。
应用程序.rb
config.exceptions_app = self.routes
路线.rb
get "/404", :to => "errors#not_found"
get "/422", :to => "errors#unacceptable"
get "/500", :to => "errors#internal_error"
errors_controller.rb
class ErrorsController < ApplicationController
def not_found
render :status => 404 end
def unacceptable
render :status => 422 end
def internal_error
render :status => 500 end
end
app/views/errors/not_found.html.erb
<label> TEST 404 Label </label>