If you want to answer 404 , I can come up with two approaches.
First, you can forward to Rack and return a simple 404 answer:
# config/routes.rb root to: proc { [404, {}, ["Not found."]] }
Secondly, you can choose the obvious route and point root to the action of the controller, which returns 404 :
# config/routes.rb root to: "application#not_found" # app/controllers/application_controller.rb def not_found render plain: "Not found.", status: 404 end
The third option, of course, is to go over to a non-existent action, but I donโt think itโs a good idea, because the intention is hidden and can easily be mistaken for an error.
source share