Performance: Why routing maps URLs to actions
Routing affects how quickly the server can match a URL to the correct controller action, impacting initial response time and perceived page load speed.
Rails.application.routes.draw do resources :articles get '/about', to: 'pages#about' end
Rails.application.routes.draw do match '*path', to: 'application#catch_all', via: :all end
| Pattern | Routing Lookup Time | Server Processing | Response Delay | Verdict |
|---|---|---|---|---|
| Catch-all wildcard route | High (checks many patterns) | Increased | Slower response | [X] Bad |
| Specific resourceful routes | Low (direct match) | Reduced | Faster response | [OK] Good |
get '/profile', to: 'users#show' and the UsersController with a show action that sets @user = User.find(1), what happens when a user visits '/profile'?get '/dashboard' 'dashboard#index'. What is the problem here?Pass the test and this pattern moves unknown