備忘録としてまとめておきます。
環境
Rails 4.1.0
設定
config/routes.rb
get '*path' => 'application#render_404'
app/controllers/application_controller.rb
unless Rails.application.config.consider_all_requests_local rescue_from ActiveRecord::RecordNotFound, :with => :render_404 rescue_from ActionController::UnknownAction, :with => :render_404 rescue_from ActionController::RoutingError, :with => :render_404 rescue_from Exception, :with => :render_500 end def render_404(exception = nil) if exception logger.info "Rendering 404 with exception: #{exception.message}" end render :file => "#{Rails.root}/public/404.html", :status => :not_found, :layout => false, :content_type => 'text/html' end def render_500(exception = nil) if exception logger.info "Rendering 500 with exception: #{exception.message}" end render :file => "#{Rails.root}/public/500.html", :status => :internal_server_error, :layout => false, :content_type => 'text/html' end
これがデフォルトなのかわからないけど、参考になれば。