Commit 2b9a25bd authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 5e9a3944
...@@ -45,6 +45,10 @@ class ApplicationController < ActionController::Base ...@@ -45,6 +45,10 @@ class ApplicationController < ActionController::Base
redirect_to request.referer.present? ? :back : default, options redirect_to request.referer.present? ? :back : default, options
end end
def not_found
render_404
end
protected protected
# This filter handles both private tokens and personal access tokens # This filter handles both private tokens and personal access tokens
......
...@@ -88,4 +88,6 @@ Rails.application.routes.draw do ...@@ -88,4 +88,6 @@ Rails.application.routes.draw do
get ':username.keys' => 'profiles/keys#get_keys', constraints: { username: /.*/ } get ':username.keys' => 'profiles/keys#get_keys', constraints: { username: /.*/ }
root to: "root#index" root to: "root#index"
get '*unmatched_route', to: 'application#not_found'
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment