Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit e0f834267642c526299189916ad9c97318c1b121 1 parent bdb1fcc
@technoweenie technoweenie authored
View
5 actionpack/CHANGELOG
@@ -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]
View
9 actionpack/lib/action_controller/mime_responds.rb
@@ -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
View
2  actionpack/test/controller/mime_responds_test.rb
@@ -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
View
0  ...t/fixtures/respond_to/all_types_with_layout.rhtml → ...ixtures/respond_to/all_types_with_layout.html.erb
File renamed without changes
View
0  ...est/fixtures/respond_to/all_types_with_layout.rjs → .../fixtures/respond_to/all_types_with_layout.js.rjs
File renamed without changes
View
0  ...es/respond_to/using_defaults_with_type_list.rhtml → .../test/fixtures/respond_to/using_defaults.html.erb
File renamed without changes
View
0  ...ures/respond_to/using_defaults_with_type_list.rjs → ...ck/test/fixtures/respond_to/using_defaults.js.rjs
File renamed without changes
View
0  ...res/respond_to/using_defaults_with_type_list.rxml → ...st/fixtures/respond_to/using_defaults.xml.builder
File renamed without changes
View
0  ...ack/test/fixtures/respond_to/using_defaults.rhtml → ...respond_to/using_defaults_with_type_list.html.erb
File renamed without changes
View
0  ...npack/test/fixtures/respond_to/using_defaults.rjs → ...s/respond_to/using_defaults_with_type_list.js.rjs
File renamed without changes
View
0  ...pack/test/fixtures/respond_to/using_defaults.rxml → ...pond_to/using_defaults_with_type_list.xml.builder
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.