Skip to content
Browse files

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
  • Loading branch information...
1 parent c2f4681 commit 39ccb5e807eadfc9bf6ac780778aa1de4d09e196 @technoweenie technoweenie committed Apr 15, 2007
Showing with 15 additions and 1 deletion.
  1. +2 −0 actionpack/CHANGELOG
  2. +13 −1 actionpack/lib/action_view/base.rb
View
2 actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* 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]
+
* The default respond_to blocks don't set a specific extension anymore, so that both 'show.rjs' and 'show.js.rjs' will work. [Rick]
* Allow layouts with extension of .html.erb. Closes #8032 [Josh Knowles]
View
14 actionpack/lib/action_view/base.rb
@@ -403,7 +403,19 @@ def file_public?(template_path)#: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

0 comments on commit 39ccb5e

Please sign in to comment.
Something went wrong with that request. Please try again.