default-routes
A route that lets a request choose the action, so every public method is one.
- Group
- Code
- Runs
- Runs under ur scan:
ur scan --rule default-routes - Level
- warning
- Reads
- Every file
- Fix
- None: which actions a route should reach is the application's to say
Why
A route whose path holds :action or *action lets a request run any public method of the controller it names, and one that also holds :controller any public method of any controller: a helper or a method meant only for other code becomes an action anyone can call, past the routes the application meant to draw, and a GET reaches actions that change data. Draw a route for each action, as resources does.
The fix, as Ur suggests it: draw a route for each action.
For agents
Draw a route for each action; never route :action or :controller from the path.
Example
config/routes.rbRails.application.routes.draw do
resources :users
get "reports/:action", controller: "reports"
end
$ ur scan --rule default-routes
warning[default-routes]: the route `"reports/:action"` lets a request name the action, so every public method of its controller is an action
--> ./config/routes.rb:3:3 `get "reports/:action", controller: "reports"`
= hint: draw a route for each action
= see: Rails Routing from the Outside In, 3.7 HTTP Verb Constraints and 3.1 Bound Parameters, Rails Guides (2025-10-01), https://guides.rubyonrails.org/routing.html
scanned 1 file (no framework recognized)
default-routes: 1 high, 0 medium
1 finding and 0 of medium confidence
Source
Rails Routing from the Outside In, 3.7 HTTP Verb Constraints and 3.1 Bound Parameters, Rails Guides (2025-10-01).