From f57ee365e154ce6d15cd168112d94a9a8ff27094 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Mon, 30 May 2005 07:51:02 +0000 Subject: render(:text), render(:partial), and render(:nothing) always default to :layout => false. This also fixes send_file, which was applying a layout if one existed for the current action. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1369 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/layout.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb index e7e8d3b834..d4ec7744aa 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -144,12 +144,12 @@ module ActionController #:nodoc: # # If most of your actions use the same layout, it makes perfect sense to define a controller-wide layout as described above. # Some times you'll have exceptions, though, where one action wants to use a different layout than the rest of the controller. - # This is possible using render_with_layout method. It's just a bit more manual work as you'll have to supply fully + # This is possible using the render method. It's just a bit more manual work as you'll have to supply fully # qualified template and layout names as this example shows: # # class WeblogController < ActionController::Base # def help - # render_with_layout "help/index", "200", "layouts/help" + # render :file => "help/index", :layout => "layouts/help" # end # end # @@ -203,7 +203,8 @@ module ActionController #:nodoc: end def render_with_a_layout(options = {}, deprecated_status = nil, deprecated_layout = nil) #:nodoc: - if (layout = pick_layout(options, deprecated_layout)) && options.is_a?(Hash) && options[:text] + options = render_with_a_layout_options(options) + if (layout = pick_layout(options, deprecated_layout)) logger.info("Rendering #{options[:template]} within #{layout}") unless logger.nil? @content_for_layout = render_with_no_layout(options.merge(:layout => false)) @@ -217,8 +218,19 @@ module ActionController #:nodoc: end private + def render_with_a_layout_options(options) + return options unless options.is_a?(Hash) + case + when options[:text], options[:partial], options[:nothing] + # by default, :text, :partial, and :nothing never use a layout + { :layout => false }.merge(options) + else + options + end + end + def pick_layout(options = {}, deprecated_layout = nil) - return deprecated_layout if !deprecated_layout.nil? || (options.is_a?(Hash) && options[:nothing]) + return deprecated_layout if !deprecated_layout.nil? if options.is_a?(Hash) case options[:layout] @@ -246,4 +258,4 @@ module ActionController #:nodoc: end end end -end \ No newline at end of file +end -- cgit v1.2.3