From 39ccb5e807eadfc9bf6ac780778aa1de4d09e196 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Sun, 15 Apr 2007 18:01:40 +0000 Subject: Tweak template format rules so that the ACCEPT header is only used if it's text/javascript. This is so ajax actions without a :format param get recognized as Mime::JS. [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6522 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/base.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 1a4234b2c9..5ae3e7ba11 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -403,7 +403,19 @@ module ActionView #:nodoc: # symbolized version of the :format parameter of the request, or :html by default. def template_format - @template_format ||= controller.request.parameters[:format].to_sym rescue :html + if @template_format.nil? + @template_format = + begin + if controller.request.accepts.first == Mime::JS + :js + else + controller.request.parameters[:format].to_sym + end + rescue + :html + end + end + @template_format end def template_handler_preferences -- cgit v1.2.3