Permalink
Browse files

Change default respond_to templates for xml and rjs formats. [Rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6507 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent bdb1fcc commit e0f834267642c526299189916ad9c97318c1b121 @technoweenie technoweenie committed Apr 8, 2007
View
@@ -1,5 +1,10 @@
*SVN*
+* Change default respond_to templates for xml and rjs formats. [Rick]
+
+ * Default xml template goes from #{action_name}.rxml => #{action_name}.xml.builder.
+ * Default rjs template goes from #{action_name}.rjs => #{action_name}.js.rjs.
+
* Fix WSOD due to modification of a formatted template extension so that requests to templates like 'foo.html.erb' fail on the second hit. [Rick]
* Fix WSOD when template compilation fails [Rick]
@@ -107,10 +107,11 @@ def respond_to(*types, &block)
end
class Responder #:nodoc:
- DEFAULT_BLOCKS = [:html, :js, :xml].inject({}) do |blocks, ext|
- template_extension = (ext == :html ? '' : ".r#{ext}")
- blocks.update ext => %(Proc.new { render :action => "\#{action_name}#{template_extension}", :content_type => Mime::#{ext.to_s.upcase} })
- end
+ default_block_format = %(Proc.new { render :action => "\#{action_name}%s", :content_type => Mime::%s })
+ DEFAULT_BLOCKS = {}
+ DEFAULT_BLOCKS[:html] = default_block_format % ['', 'HTML']
+ DEFAULT_BLOCKS[:js] = default_block_format % ['.js.rjs', 'JS']
+ DEFAULT_BLOCKS[:xml] = default_block_format % ['.xml.builder', 'XML']
def initialize(block_binding)
@block_binding = block_binding
@@ -351,6 +351,6 @@ def render(*args)
assert_equal "using_defaults", @response.body
get :using_defaults, :format => "xml"
- assert_equal "using_defaults.rxml", @response.body
+ assert_equal "using_defaults.xml.builder", @response.body
end
end

0 comments on commit e0f8342

Please sign in to comment.