Configure routes in config/routes.rb to match incoming HTTP requests to controller actions via the URL path, optionally forwarding to Rack applications. When defining routes, use the to: option with controller#action format, or separate controller: and action: options. Specify controller names in snake_case, such as user_profiles#show for UserProfilesController. The router generates path and URL helpers to avoid hard-coded strings in views. Use the as: option to provide custom helper names. For example, user_path(@user) generates relative paths like /users/17, while user_url creates absolute URLs. These helpers allow views to remain unchanged if routes move to different URLs. Incoming requests with parameters like GET /users/17 are matched to specific actions, populating the params hash with extracted values like id. This approach ensures robust routing by dynamically generating links and handling request matching based on configured resources. Scope: Rails. Reviewed October 4, 2026.
Routing and resources
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- guides.rubyonrails.org
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.