提交 211dd25e 编写于 作者: J John Hawthorn

Remove obsolete or discouraged render examples

Most of these examples no longer work. The ability to render an absolute
path was removed as part of CVE-2016-0752. In Rails 6 we changed `render
file:` to only take exact paths and always to render them as raw files.
Rendering a template with its extensions _is_ supported, but I don't
think should be recommended.

This also removes `render file:` from an example where it isn't
relevant.

[ci skip]
上级 08f85239
...@@ -178,17 +178,9 @@ In fact, in the BooksController class, inside of the update action where we want ...@@ -178,17 +178,9 @@ In fact, in the BooksController class, inside of the update action where we want
render :edit render :edit
render action: :edit render action: :edit
render "edit" render "edit"
render "edit.html.erb"
render action: "edit" render action: "edit"
render action: "edit.html.erb"
render "books/edit" render "books/edit"
render "books/edit.html.erb"
render template: "books/edit" render template: "books/edit"
render template: "books/edit.html.erb"
render "/path/to/rails/app/views/books/edit"
render "/path/to/rails/app/views/books/edit.html.erb"
render file: "/path/to/rails/app/views/books/edit"
render file: "/path/to/rails/app/views/books/edit.html.erb"
``` ```
Which one you use is really a matter of style and convention, but the rule of thumb is to use the simplest one that makes sense for the code you are writing. Which one you use is really a matter of style and convention, but the rule of thumb is to use the simplest one that makes sense for the code you are writing.
...@@ -303,7 +295,7 @@ Calls to the `render` method generally accept five options: ...@@ -303,7 +295,7 @@ Calls to the `render` method generally accept five options:
By default, Rails will serve the results of a rendering operation with the MIME content-type of `text/html` (or `application/json` if you use the `:json` option, or `application/xml` for the `:xml` option.). There are times when you might like to change this, and you can do so by setting the `:content_type` option: By default, Rails will serve the results of a rendering operation with the MIME content-type of `text/html` (or `application/json` if you use the `:json` option, or `application/xml` for the `:xml` option.). There are times when you might like to change this, and you can do so by setting the `:content_type` option:
```ruby ```ruby
render file: filename, content_type: "application/rss" render template: "feed", content_type: "application/rss"
``` ```
##### The `:layout` Option ##### The `:layout` Option
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册