aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/rendering.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/metal/rendering.rb')
-rw-r--r--actionpack/lib/action_controller/metal/rendering.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb
index 2d58e1440c..d965cb8c16 100644
--- a/actionpack/lib/action_controller/metal/rendering.rb
+++ b/actionpack/lib/action_controller/metal/rendering.rb
@@ -6,15 +6,28 @@ module ActionController
# :api: public
def render(*args, &block)
super(*args, &block)
- text = args.first[:text]
- if text.present?
- self.response_body = text
+ opts = args.first
+ if (opts.keys & [:text, :nothing]).present?
+ self.response_body = if opts.has_key?(:text) && opts[:text].present?
+ opts[:text]
+ elsif opts.has_key?(:nothing) && opts[:nothing]
+ " "
+ end
+ else
+ raise UnsupportedOperationError
end
end
def rendered_format
Mime::TEXT
end
+
+ class UnsupportedOperationError < StandardError
+ def initialize
+ super "Unsupported render operation. BasicRendering supports only :text
+ and :nothing options. For more, you need to include ActionView."
+ end
+ end
end
module Rendering