diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-09-17 18:10:25 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-09-17 18:10:25 +0000 |
commit | caa8a005202b267b75baf521d5f613f3a2bce600 (patch) | |
tree | df72b8673b625b22037895a81b672a8b1650d5a6 /actionpack/lib | |
parent | 98a412aa3853b9e31b747f53e58a841966df5f1b (diff) | |
download | rails-caa8a005202b267b75baf521d5f613f3a2bce600.tar.gz rails-caa8a005202b267b75baf521d5f613f3a2bce600.tar.bz2 rails-caa8a005202b267b75baf521d5f613f3a2bce600.zip |
Added that respond_to blocks will automatically set the content type to be the same as is requested [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5131 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/mime_responds.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/mime_responds.rb b/actionpack/lib/action_controller/mime_responds.rb index 07bbbb4732..6c721f4ba2 100644 --- a/actionpack/lib/action_controller/mime_responds.rb +++ b/actionpack/lib/action_controller/mime_responds.rb @@ -108,7 +108,7 @@ module ActionController #:nodoc: class Responder #:nodoc: DEFAULT_BLOCKS = [:html, :js, :xml].inject({}) do |blocks, ext| - blocks.update ext => %(Proc.new { render :action => "\#{action_name}.r#{ext}" }) + blocks.update ext => %(Proc.new { render :action => "\#{action_name}.r#{ext}", :content_type => Mime::#{ext.to_s.upcase} }) end def initialize(block_binding) @@ -129,7 +129,10 @@ module ActionController #:nodoc: @order << mime_type if block_given? - @responses[mime_type] = block + @responses[mime_type] = Proc.new do + eval "response.content_type = Mime::#{mime_type.to_sym.to_s.upcase}", @block_binding + block.call + end else if source = DEFAULT_BLOCKS[mime_type.to_sym] @responses[mime_type] = eval(source, @block_binding) |