Rails 2.0.1 has added the ability to ensure that the method being requested is a valid HTTP method. It defines the list of acceptable methods in actionpack/lib/action_controller/request.rb as:
ACCEPTED_HTTP_METHODS = Set.new(%w( get head put post delete ))
Missing from this list is OPTIONS. I (and many others) use OPTIONS request for several things:
- When building RESTful services, an OPTIONS request to a URL should return the methods that resource will respond to.
- When using mongrel behind a reverse proxy (such as Perlbal,) it is common to use an OPTIONS request to ensure that rails is ready to receive a new request (as opposed to mongrel simply accepting the TCP connection.)
Attached is a patch, enabling OPTIONS requests by default.
As a workaround, you can override the constant by placing:
module ActionController
# HTTP methods which are accepted by default.
ACCEPTED_HTTP_METHODS = Set.new(%w( get head put post delete options ))
end
At the end of environments.rb, although this will generate a warning.