aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/base.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-06-27 11:29:04 +0300
committerMichael Koziarski <michael@koziarski.com>2008-07-07 07:31:49 +0200
commit2f4aaed7b3feb3be787a316fab3144c06bb21a27 (patch)
tree77604663cd08612a2bbacf1901662ce7ececcf69 /actionpack/lib/action_controller/base.rb
parentafa0c7f728a8896c9ee9d932033e08a4c99dfd50 (diff)
downloadrails-2f4aaed7b3feb3be787a316fab3144c06bb21a27.tar.gz
rails-2f4aaed7b3feb3be787a316fab3144c06bb21a27.tar.bz2
rails-2f4aaed7b3feb3be787a316fab3144c06bb21a27.zip
Disable the Accept header by default
The accept header is poorly implemented by browsers and causes strange errors when used on public sites where crawlers make requests too. You should use formatted urls (e.g. /people/1.xml) to support API clients. Alternatively to re-enable it you need to set: config.action_controller.use_accept_header = true A special case remains for ajax requests which will have a javascript format for the base resource (/people/1) if the X-Requested-With header is present. This lets ajax pages still use format.js despite there being no params[:format]
Diffstat (limited to 'actionpack/lib/action_controller/base.rb')
-rwxr-xr-xactionpack/lib/action_controller/base.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 58eb5cabcd..c28e9005cf 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -340,6 +340,16 @@ module ActionController #:nodoc:
cattr_accessor :optimise_named_routes
self.optimise_named_routes = true
+ # Indicates whether the response format should be determined by examining the Accept HTTP header,
+ # or by using the simpler params + ajax rules.
+ #
+ # If this is set to +true+ then +respond_to+ and +Request#format+ will take the Accept header into
+ # account. If it is set to false (the default) then the request format will be determined solely
+ # by examining params[:format]. If params format is missing, the format will be either HTML or
+ # Javascript depending on whether the request is an AJAX request.
+ cattr_accessor :use_accept_header
+ self.use_accept_header = false
+
# Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode.
class_inheritable_accessor :allow_forgery_protection
self.allow_forgery_protection = true