Be explicit about allowed constraint values, fixes #14702
This commit is contained in:
parent
142448259d
commit
aca64fed43
@ -694,6 +694,8 @@ namespace :admin do
|
||||
end
|
||||
```
|
||||
|
||||
NOTE: Request constraints work by calling a method on the <a href="action_controller_overview.html#the-request-object">Request object</a> with the same name as the hash key and then compare the return value with the hash value. Therefore, constraint values should match the corresponding Request object method return type. For example: `constraints: { subdomain: 'api' }` will match an `api` subdomain as expected, however using a symbol `constraints: { subdomain: :api }` will not, because `request.subdomain` returns `'api'` as a String.
|
||||
|
||||
### Advanced Constraints
|
||||
|
||||
If you have a more advanced constraint, you can provide an object that responds to `matches?` that Rails should use. Let's say you wanted to route all users on a blacklist to the `BlacklistController`. You could do:
|
||||
|
Loading…
Reference in New Issue
Block a user