From d50df2f116bfb1f3e897746fb345a5e945650e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20=C5=9Awirski?= Date: Mon, 1 Apr 2013 15:06:36 +0200 Subject: [PATCH] Reverts rendering behavior when format is unknown If a request has unknown format (eg. /foo.bar), the renderer fallbacks to default format. This patch reverts Rails 3.2 behavior after c2267db commit. Fixes issue #9654. --- actionpack/lib/action_controller/metal/rendering.rb | 2 +- actionpack/lib/action_dispatch/http/mime_type.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index c5e7d4e357..eabc0fc230 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -6,7 +6,7 @@ module ActionController # Before processing, set the request formats in current controller formats. def process_action(*) #:nodoc: - self.formats = request.formats.map { |x| x.ref } + self.formats = request.formats.select { |x| !x.nil? }.map(&:ref) super end diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index 049840e2e1..c24c9a1bc3 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -306,12 +306,16 @@ module Mime method.to_s.ends_with? '?' end end - + class NullType def nil? true end + def respond_to_missing?(method, include_private = false) + method.to_s.ends_with? '?' + end + private def method_missing(method, *args) false if method.to_s.ends_with? '?'