diff options
author | Prem Sichanugrist <s@sikac.hu> | 2014-02-18 09:30:43 -0500 |
---|---|---|
committer | Prem Sichanugrist <s@sikac.hu> | 2014-02-18 12:11:41 -0500 |
commit | ede0f8c62d825089e6676c2af7a035bd8ca94b01 (patch) | |
tree | d36b2230069551381d63f22069b53adba37eb3c1 /guides | |
parent | 3047376870d4a7adc7ff15c3cb4852e073c8f1da (diff) | |
download | rails-ede0f8c62d825089e6676c2af7a035bd8ca94b01.tar.gz rails-ede0f8c62d825089e6676c2af7a035bd8ca94b01.tar.bz2 rails-ede0f8c62d825089e6676c2af7a035bd8ca94b01.zip |
Update upgrading guide regarding `render :text`
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/upgrading_ruby_on_rails.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index 76722c9ea9..a8b7c9d492 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -329,6 +329,25 @@ User.inactive # SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive' ``` +### Rendering content from string + +Rails 4.1 introduces `:plain`, `:html`, and `:body` options to `render`. Those +options are now the preferred way to render string-based content, as it allows +you to specify which content type you want the response sent as. + +* `render :plain` will set the content type to `text/plain` +* `render :html` will set the content type to `text/html` +* `render :body` will *not* set the content type header. + +From the security standpoint, if you don't expect to have any markup in your +response body, you should be using `render :plain` as most browsers will escape +unsafe content in the response for you. + +We will be deprecating the use of `render :text` in a future version. So please +start using the more precise `:plain:`, `:html`, and `:body` options instead. +Using `render :text` may pose a security risk, as the content is sent as +`text/html`. + Upgrading from Rails 3.2 to Rails 4.0 ------------------------------------- |