Permalink
Browse files

Merge pull request #27365 from baweaver/patch-1

Add note on defaults block option
  • Loading branch information...
eileencodes committed Dec 19, 2016
2 parents 6e6b00f + 6a116bd commit b61fa5c97efc2dadaeea2959da948b32a5af85b8
Showing with 8 additions and 0 deletions.
  1. +8 −0 guides/source/routing.md
View
@@ -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

0 comments on commit b61fa5c

Please sign in to comment.