aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/abstract_controller/collector.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/abstract_controller/collector.rb')
-rw-r--r--actionpack/lib/abstract_controller/collector.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/actionpack/lib/abstract_controller/collector.rb b/actionpack/lib/abstract_controller/collector.rb
index f7a309c26c..ddd56b354a 100644
--- a/actionpack/lib/abstract_controller/collector.rb
+++ b/actionpack/lib/abstract_controller/collector.rb
@@ -23,15 +23,17 @@ module AbstractController
protected
def method_missing(symbol, &block)
- mime_const = symbol.upcase
-
- raise NoMethodError, "To respond to a custom format, register it as a MIME type first:" +
- "http://guides.rubyonrails.org/action_controller_overview.html#restful-downloads." +
- "If you meant to respond to a variant like :tablet or :phone, not a custom format," +
- "be sure to nest your variant response within a format response: format.html" +
- "{ |html| html.tablet { ..." unless Mime.const_defined?(mime_const)
+ const_name = symbol.upcase
+
+ unless Mime.const_defined?(const_name)
+ raise NoMethodError, "To respond to a custom format, register it as a MIME type first: " \
+ "http://guides.rubyonrails.org/action_controller_overview.html#restful-downloads. " \
+ "If you meant to respond to a variant like :tablet or :phone, not a custom format, " \
+ "be sure to nest your variant response within a format response: " \
+ "format.html { |html| html.tablet { ... } }"
+ end
- mime_constant = Mime.const_get(mime_const)
+ mime_constant = Mime.const_get(const_name)
if Mime::SET.include?(mime_constant)
AbstractController::Collector.generate_method_for_mime(mime_constant)