Skip to content

Commit 7da99f7

Browse files
authored
Explains that application/pdf is already registered by Rails
In the example about RESTful downloads and PDFs, the Guides ask to register the `application/pdf` MIME type in Rails explicitly. This step doesn't seem necessary because the PDF type is already registered by Rails by default.
1 parent ac1d768 commit 7da99f7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

guides/source/action_controller_overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,10 +1073,10 @@ class ClientsController < ApplicationController
10731073
end
10741074
```
10751075

1076-
For this example to work, you have to add the PDF MIME type to Rails. This can be done by adding the following line to the file `config/initializers/mime_types.rb`:
1076+
This example works because [Rails already registers the `"application/pdf"` MIME type](https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/http/mime_types.rb) at startup (alongside other common types). If you need additional MIME types, call [`Mime::Type.register`](https://api.rubyonrails.org/classes/Mime/Type.html#method-c-register) in the file `config/initializers/mime_types.rb`. For example:
10771077

10781078
```ruby
1079-
Mime::Type.register "application/pdf", :pdf
1079+
Mime::Type.register(<mime_type>, <symbol>)
10801080
```
10811081

10821082
NOTE: Configuration files are not reloaded on each request, so you have to restart the server for their changes to take effect.

0 commit comments

Comments
 (0)