aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/rendering.rb
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikac.hu>2014-03-23 20:16:07 -0400
committerPrem Sichanugrist <s@sikac.hu>2015-07-17 21:12:47 -0400
commit6790228b39dd070b93054c463162de28f67d3ccc (patch)
treedc039e7649743bd6a33ff2598cf3672a65826343 /actionpack/lib/action_controller/metal/rendering.rb
parent2c79122c0bbd61dcef12b95c80e025490d5a9783 (diff)
downloadrails-6790228b39dd070b93054c463162de28f67d3ccc.tar.gz
rails-6790228b39dd070b93054c463162de28f67d3ccc.tar.bz2
rails-6790228b39dd070b93054c463162de28f67d3ccc.zip
Add deprecation warning for `render :text`
We've started on discouraging the usage of `render :text` in #12374. This is a follow-up commit to make sure that we print out the deprecation warning.
Diffstat (limited to 'actionpack/lib/action_controller/metal/rendering.rb')
-rw-r--r--actionpack/lib/action_controller/metal/rendering.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb
index b9ae8dd5ea..a3b0645dc0 100644
--- a/actionpack/lib/action_controller/metal/rendering.rb
+++ b/actionpack/lib/action_controller/metal/rendering.rb
@@ -1,3 +1,6 @@
+require 'active_support/deprecation'
+require 'active_support/core_ext/string/filters'
+
module ActionController
module Rendering
extend ActiveSupport::Concern
@@ -74,6 +77,17 @@ module ActionController
def _normalize_options(options) #:nodoc:
_normalize_text(options)
+ if options[:text]
+ ActiveSupport::Deprecation.warn <<-WARNING.squish
+ `render :text` is deprecated because it does not actually render a
+ `text/plain` response. Switch to `render plain: 'plain text'` to
+ render as `text/plain`, `render html: '<strong>HTML</strong>'` to
+ render as `text/html`, or `render body: 'raw'` to match the deprecated
+ behavior and render with the default Content-Type, which is
+ `text/plain`.
+ WARNING
+ end
+
if options[:html]
options[:html] = ERB::Util.html_escape(options[:html])
end