diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-12-03 22:23:11 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-12-03 22:23:12 -0200 |
commit | 3b40a5d83db90534b3cb61f4dc25547f501e4775 (patch) | |
tree | 49795acfdaaf3c5b468ddcbea474709cabf54b2e /actionpack/lib/abstract_controller/collector.rb | |
parent | bc26f442d2ef31facc493f4db518f6e104a4f14d (diff) | |
download | rails-3b40a5d83db90534b3cb61f4dc25547f501e4775.tar.gz rails-3b40a5d83db90534b3cb61f4dc25547f501e4775.tar.bz2 rails-3b40a5d83db90534b3cb61f4dc25547f501e4775.zip |
Improve a couple exception messages related to variants and mime types
Avoid one-liner conditionals when they are too big. Avoid concatenating
strings to build error messages. Improve messages a bit.
Diffstat (limited to 'actionpack/lib/abstract_controller/collector.rb')
-rw-r--r-- | actionpack/lib/abstract_controller/collector.rb | 18 |
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) |