What are named routes in Rails?

Answer

Named routes give a URL pattern a name, generating helper methods for constructing URLs. resources :posts creates posts_path (returns /posts), new_post_path, post_path(@post), and edit_post_path(@post). For custom routes: get '/about', to: 'pages#about', as: 'about' creates about_path. Named routes produce both _path (relative URL) and _url (absolute URL with host) helpers. Using named route helpers instead of hardcoded strings makes code refactoring easier — change the URL in one place and all helpers update automatically.