Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails - how to handle routes that don't exist ("No route matches [GET]")?

My route looks like

match 'about' => 'company#about'

When I set to the url http://localhost:3000/aboutttt, I get the error message

No route matches [GET] "/aboutttt"

I want to give the user better feedback than that.

The best solution by my opinion could be redirect the app back, or on the homepage of the app, but exist in routes any way to set default route, when I get the error above?

like image 454
user984621 Avatar asked Dec 16 '22 01:12

user984621


1 Answers

While you are on development. Make changes inside config/environments/development.rb by setting: config.consider_all_requests_local = false

This will disable full error reporting and instead shows a page with interactive response for users. But this is already disabled on production environment. But I don't recommend turning it off in development mode.

like image 59
Tenzin Chemi Avatar answered Feb 16 '23 01:02

Tenzin Chemi