aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/abstract_controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/abstract_controller')
-rw-r--r--actionpack/lib/abstract_controller/collector.rb10
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb2
2 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/lib/abstract_controller/collector.rb b/actionpack/lib/abstract_controller/collector.rb
index 09b9e7ddf0..f7a309c26c 100644
--- a/actionpack/lib/abstract_controller/collector.rb
+++ b/actionpack/lib/abstract_controller/collector.rb
@@ -23,7 +23,15 @@ module AbstractController
protected
def method_missing(symbol, &block)
- mime_constant = Mime.const_get(symbol.upcase)
+ 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)
+
+ mime_constant = Mime.const_get(mime_const)
if Mime::SET.include?(mime_constant)
AbstractController::Collector.generate_method_for_mime(mime_constant)
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index fb8f40cb9b..ce3a0316c4 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -102,6 +102,8 @@ module AbstractController
# :api: private
def _normalize_render(*args, &block)
options = _normalize_args(*args, &block)
+ #TODO: remove defined? when we restore AP <=> AV dependency
+ options[:variant] = request.variant if defined?(request) && request.variant.present?
_normalize_options(options)
options
end