From 8e2fd54b19656a6edbd94f8707927d09e167e7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 20 Jan 2010 14:21:27 +0100 Subject: Bring normalize behavior to AbstractController::Rendering --- actionpack/lib/action_controller/metal/rendering.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_controller/metal/rendering.rb') diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 74e50bb032..475ed54167 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -12,9 +12,10 @@ module ActionController super end - def render(options) - super - self.content_type ||= options[:_template].mime_type.to_s + def render(*args) + args << {} unless args.last.is_a?(Hash) + super(*args) + self.content_type ||= args.last[:_template].mime_type.to_s response_body end -- cgit v1.2.3 From d618b7e3dcf2fe6040f025c02bf29691aefc8a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 22 Jan 2010 17:57:36 +0100 Subject: Ensure strings given to render with slash are rendered relative to the configured _prefix. --- .../lib/action_controller/metal/rendering.rb | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'actionpack/lib/action_controller/metal/rendering.rb') diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 475ed54167..72e2bbd00e 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -25,18 +25,6 @@ module ActionController end private - def _prefix - controller_path - end - - def _determine_template(options) - if (options.keys & [:partial, :file, :template, :text, :inline]).empty? - options[:_template_name] ||= options[:action] - options[:_prefix] = _prefix - end - - super - end def _render_partial(options) options[:partial] = action_name if options[:partial] == true @@ -54,5 +42,29 @@ module ActionController self.content_type = content_type if content_type self.headers["Location"] = url_for(location) if location end + + def _normalize_options(action=nil, options={}, &blk) + case action + when NilClass + when Hash + options = super(action.delete(:action), action) + when String, Symbol + options = super + else + options.merge! :partial => action + end + + if (options.keys & [:partial, :file, :template, :text, :inline]).empty? + options[:_template_name] ||= options[:action] + options[:_prefix] = _prefix + end + + if options[:status] + options[:status] = Rack::Utils.status_code(options[:status]) + end + + options[:update] = blk if block_given? + options + end end end -- cgit v1.2.3