Ruby on rails 为什么Rails重定向了我的帖子,却没有得到它?

Ruby on rails 为什么Rails重定向了我的帖子,却没有得到它?,ruby-on-rails,redirect,Ruby On Rails,Redirect,我试图将数据发布到某个控制器#action对,但我的应用程序在post上重定向了我(但没有GET),我不知道为什么 我用一种方法构建了一个裸体控制器: class NavigationsController < ApplicationController def foo render :text => 'in foo' end end 不过,以下是我获得并发布的结果: $ curl http://localhost:3000/navigations/

我试图将数据发布到某个
控制器#action
对,但我的应用程序在post上重定向了我(但没有GET),我不知道为什么

我用一种方法构建了一个裸体控制器:

class NavigationsController < ApplicationController
    def foo
        render :text => 'in foo'
    end
end
不过,以下是我获得并发布的结果:

$ curl http://localhost:3000/navigations/foo/1
in foo
$ curl -d 'a=b' http://localhost:3000/navigations/foo/1
<html><body>You are being <a href="http://localhost:3000/">redirected</a>.</body></html>
$curlhttp://localhost:3000/navigations/foo/1
因福
$curl-d'a=b'http://localhost:3000/navigations/foo/1
你是在逃避责任。

规格:rails 2.3.8,ruby 1.8.7

关闭
防止伪造

对于所有控制器 在ApplicationController中注释掉(或删除)
防止伪造

class ApplicationController < ActionController::Base
    #protect_from_forgery # See ActionController::RequestForgeryProtection for details
    # ...
end
用于一个或多个操作 在前面的
过滤之前跳过
防止伪造
命令中添加
:除
选项外

class MyController < ApplicationController
    protect_from_forgery :except => :index
end

class MyOtherController < ApplicationController
    skip_before_filter :verify_authenticity_token, :except => [:create]
end
class MyController:索引
结束
类MyOtherController<应用程序控制器
在筛选器之前跳过\u:验证\u真实性\u令牌,:except=>[:create]
结束

您的日志是否显示了有趣的内容?没有。只是我被重定向了。请列出你的宝石和插件。一个合理的说明。然而,问题在于
防止伪造的禁令。接受你自己的答案没有错。这个问题对其他人也是有用的,所以请考虑不要删除它。
class NavsController < ApplicationController
    skip_before_filter :verify_authenticity_token
    # ...
end
class MyController < ApplicationController
    protect_from_forgery :except => :index
end

class MyOtherController < ApplicationController
    skip_before_filter :verify_authenticity_token, :except => [:create]
end