This is already the default behavior in production. The development environment displays routing errors so that the developer can notice and correct them.
If you want to try, start the server in production mode and check it.
$ script/rails s -e production
source share