Ruby on rails 对my Rails应用程序的Ajax请求:301已永久移动

Ruby on rails 对my Rails应用程序的Ajax请求:301已永久移动,ruby-on-rails,Ruby On Rails,我正在向我的Rails应用程序发送post请求: $.ajax url: "/" + locale + "/administration/dashboards/remove_tag_named.json" type: "POST" dataType: "json", contentType: "json" data: {"tag_name": "bingo" } success: (result) -> ..... 我可以在控制台中看到帖子,但是我没有

我正在向我的Rails应用程序发送post请求:

 $.ajax 
  url: "/" + locale + "/administration/dashboards/remove_tag_named.json"
  type: "POST"
  dataType: "json",
  contentType: "json"
  data: {"tag_name": "bingo" }
  success: (result) ->
    .....
我可以在控制台中看到帖子,但是我没有获得成功,在帖子发布后,我看到很多get请求被列出

[19:37:00.052] POST http://localhost:3000/fr/administration/dashboards/remove_tag_named.json [HTTP/1.1 301 Moved Permanently 42ms]
Started GET "/fr/administration%2Fdashboards%2Fremove_tag_named.json" for 127.0.0.1 at 2013-01-16 19:32:31 +0100
Started GET "/fr/administration%2Fdashboards%2Fremove_tag_named.json" for 127.0.0.1 at 2013-01-16 19:32:31 +0100
....
在我的rails应用程序中,我有

  respond_to :html, :json
  .....
  def remove_tag_named
    # should remove the tag from the table
    respond_to do |format|
      format.html { redirect_to administration_dashboards_url, notice: t(:tag_deleted) }
      format.json { head :no_content }
    end
  end
有什么不对劲吗?是jqueryajax请求还是Rails响应? 如果我尝试在Rails操作中插入调试器,则不会发生任何事情

  I have checked my routes and it's ok :

    remove_tag_named_administration_dashboards_fr POST /fr/administration/console/remove_tag_named(.:format)    administration/dashboards#remove_tag_named {:locale=>"fr"}

   remove_tag_named_administration_dashboards_en POST /en/administration/dashboards/remove_tag_named(.:format) administration/dashboards#remove_tag_named {:locale=>"en"}

这一行是ajax响应。除了204状态码之外,你没有发送任何东西

format.json { head :no_content }
另外,您可能希望*remove\u tag\u named*方法具有错误条件

def remove_tag_named
  @tag = # get tag properly
  respond_to do |format|
    if @tag.destroy
      format.html { redirect_to administration_dashboards_url, notice: t(:tag_deleted) }
      format.json { head :no_content }
    else
      format.html { # handle error condition }
      format.json { # return error info }
    end
end

谢谢,有什么原因我不能插入一个调试器语句def remove_tag_named debugger似乎不是接受帐户我对调试器不太熟悉。当它以1.9的成绩打破时,我放弃了它。我通常使用pry REPL进行调试。我知道binding.pry插入内联将起作用。还可以查看更好的错误gem,它将为您提供更有用的错误堆栈跟踪。如果需要,您甚至可以添加一个REPL.:)