[英]error :Only get requests are allowed
i get this exception 我得到这个例外
ActionController::MethodNotAllowed: Only get requests are allowed. ActionController :: MethodNotAllowed:仅允许get请求。
please can any one give solution for this 请任何人为此提供解决方案
This error means you are trying to post/put/delete to a path that only accepts GET requests. 此错误表示您正试图将其发布/放置/删除到仅接受GET请求的路径。 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. 当您定义了标准路由并且客户端尝试使用不同于GET或POST的HTTP方法连接到该路由时,会发生此错误。
Usually, this is caused by clients using the Microsoft Office Protocol Discovery. 通常,这是由使用Microsoft Office Protocol Discovery的客户端引起的。 These clients send an OPTION request which is not supported by Rails.
这些客户端发送一个OPTION请求 ,Rails不支持该请求 。
You can fix the problem in multiple ways: 您可以通过多种方式解决问题:
head 406
in your controller head 406
防止错误 rescue_from
in your controller rescue_from
来挽救错误 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.
看来您正在尝试进行其他类型的RESTful调用(放置,发布,删除)和该方法。 A code snipped of that controller would be really helpful to diagnose the problem.
删除该控制器的代码对诊断问题确实很有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.