error :Only get requests are allowed
i get this exception
ActionController::MethodNotAllowed: Only get requests are allowed.
please can any one giv开发者_如何学编程e solution for this
This error means you are trying to post/put/delete to a path that only accepts GET requests. You need to confirm that your route and the path and/or form method you are using match up.
This error occurs when you have defined a standard route and a client is trying to connect to the route using a HTTP method different than GET or POST.
Usually, this is caused by clients using the Microsoft Office Protocol Discovery. These clients send an OPTION request which is not supported by Rails.
You can fix the problem in multiple ways:
- ignore the error in your production environment
- prevent the error using a before_filter and
head 406
in your controller - rescue the error using
rescue_from
in your controller - prevent the error filtering the request via Rack Middleware
- prevent the error blocking non GET/POST/HEAD requests using your webserver
I personally prefer the last option, but it requires you to have administration privileges on the server. Otherwise, the Rack Middleware option is the most efficient way to filter unexpected requests.
How are you trying to get to this page? It looks like you are trying to do some other kind of RESTful call (put, post, delete) and that method. A code snipped of that controller would be really helpful to diagnose the problem.
精彩评论