Handle unmatched routing with not_found method

We need this to prevent routing error when user access URL like /123
when there is no resource located under such name
Signed-off-by: NDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
上级 5e9a3944
......@@ -45,6 +45,10 @@ class ApplicationController < ActionController::Base
redirect_to request.referer.present? ? :back : default, options
end
def not_found
render_404
end
protected
# This filter handles both private tokens and personal access tokens
......
......@@ -88,4 +88,6 @@ Rails.application.routes.draw do
get ':username.keys' => 'profiles/keys#get_keys', constraints: { username: /.*/ }
root to: "root#index"
get '*unmatched_route', to: 'application#not_found'
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册