aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/routing.md
diff options
context:
space:
mode:
authorJano Suchal <johno@jsmf.net>2014-04-11 15:19:37 +0200
committerJano Suchal <johno@jsmf.net>2014-04-11 15:19:37 +0200
commitaca64fed43d0c9eafabaf6a36c749796783c899c (patch)
treeb6b272fed1140961b55034de0e51b29f9dccd4df /guides/source/routing.md
parent142448259d7f450df49fdac06bf912edfecaa633 (diff)
downloadrails-aca64fed43d0c9eafabaf6a36c749796783c899c.tar.gz
rails-aca64fed43d0c9eafabaf6a36c749796783c899c.tar.bz2
rails-aca64fed43d0c9eafabaf6a36c749796783c899c.zip
Be explicit about allowed constraint values, fixes #14702
Diffstat (limited to 'guides/source/routing.md')
-rw-r--r--guides/source/routing.md2
1 files changed, 2 insertions, 0 deletions
diff --git a/guides/source/routing.md b/guides/source/routing.md
index eef618f28d..921658a71e 100644
--- a/guides/source/routing.md
+++ b/guides/source/routing.md
@@ -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: