aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2016-12-19 09:25:58 -0500
committerGitHub <noreply@github.com>2016-12-19 09:25:58 -0500
commitb61fa5c97efc2dadaeea2959da948b32a5af85b8 (patch)
tree5872e9aa69f1440c88c521dc1cc29c4cc5435563 /guides/source
parent6e6b00f3423f0e79fb0078dada1096da54bb06a8 (diff)
parent6a116bd9091fc68dc26317b398ebcbdfe8c34155 (diff)
downloadrails-b61fa5c97efc2dadaeea2959da948b32a5af85b8.tar.gz
rails-b61fa5c97efc2dadaeea2959da948b32a5af85b8.tar.bz2
rails-b61fa5c97efc2dadaeea2959da948b32a5af85b8.zip
Merge pull request #27365 from baweaver/patch-1
Add note on defaults block option
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/routing.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/guides/source/routing.md b/guides/source/routing.md
index 937e313663..86492a9332 100644
--- a/guides/source/routing.md
+++ b/guides/source/routing.md
@@ -603,6 +603,14 @@ get 'photos/:id', to: 'photos#show', defaults: { format: 'jpg' }
Rails would match `photos/12` to the `show` action of `PhotosController`, and set `params[:format]` to `"jpg"`.
+You can also use `defaults` in a block format to define the defaults for multiple items:
+
+```ruby
+defaults format: :json do
+ resources :photos
+end
+```
+
NOTE: You cannot override defaults via query parameters - this is for security reasons. The only defaults that can be overridden are dynamic segments via substitution in the URL path.
### Naming Routes