开发者

error :Only get requests are allowed

开发者 https://www.devze.com 2022-12-16 21:52 出处:网络
i get this exception ActionController::MethodNotAllowed: Only get requests are allowed. please can any one giv开发者_如何学编程e solution for thisThis error means you are trying to post/put/delete t

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:

  1. ignore the error in your production environment
  2. prevent the error using a before_filter and head 406 in your controller
  3. rescue the error using rescue_from in your controller
  4. prevent the error filtering the request via Rack Middleware
  5. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号