aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/mime_responds.rb
diff options
context:
space:
mode:
authorTobias Lütke <tobias.luetke@gmail.com>2006-08-30 00:34:36 +0000
committerTobias Lütke <tobias.luetke@gmail.com>2006-08-30 00:34:36 +0000
commitff063d700d2fda2076217ab0479e8602253ab49c (patch)
treef702ff587de6e648cf6746da7d01fa959efd37ae /actionpack/lib/action_controller/mime_responds.rb
parent3704088ebde5ef074d186bff0d380858a9a01055 (diff)
downloadrails-ff063d700d2fda2076217ab0479e8602253ab49c.tar.gz
rails-ff063d700d2fda2076217ab0479e8602253ab49c.tar.bz2
rails-ff063d700d2fda2076217ab0479e8602253ab49c.zip
respond_to .html now always renders #{action_name}.rhtml so that registered custom template handlers do not override it in priority.
Custom mime types require a block and throw proper error now. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4860 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/mime_responds.rb')
-rw-r--r--actionpack/lib/action_controller/mime_responds.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/mime_responds.rb b/actionpack/lib/action_controller/mime_responds.rb
index fd9af05905..21905b26c8 100644
--- a/actionpack/lib/action_controller/mime_responds.rb
+++ b/actionpack/lib/action_controller/mime_responds.rb
@@ -108,11 +108,9 @@ module ActionController #:nodoc:
end
class Responder #:nodoc:
- DEFAULT_BLOCKS = {
- :html => 'Proc.new { render }',
- :js => 'Proc.new { render :action => "#{action_name}.rjs" }',
- :xml => 'Proc.new { render :action => "#{action_name}.rxml" }'
- }
+ DEFAULT_BLOCKS = [:html, :js, :xml].inject({}) do |blocks, ext|
+ blocks.update ext => %(Proc.new { render :action => "\#{action_name}.r#{ext}" })
+ end
def initialize(block_binding)
@block_binding = block_binding
@@ -134,7 +132,11 @@ module ActionController #:nodoc:
if block_given?
@responses[mime_type] = block
else
- @responses[mime_type] = eval(DEFAULT_BLOCKS[mime_type.to_sym], @block_binding)
+ if source = DEFAULT_BLOCKS[mime_type.to_sym]
+ @responses[mime_type] = eval(source, @block_binding)
+ else
+ raise ActionController::RenderError, "Expected a block but none was given for custom mime handler #{mime_type}"
+ end
end
end