0

我有一个使用 Heroku 部署的 Rails 应用程序。当我在本地运行应用程序时,我能够在提交表单后成功重定向。但是,在 Heroku 上,它似乎没有进行重定向。

这是我在 Heroku 的日志:

2013-05-23T03:07:34.010275+00:00 app[web.1]: Started PUT "/projects/1/steps/0" for 76.118.180.235 at 2013-05-23 03:07:34 +0000

2013-05-23T03:07:34.940208+00:00 app[web.1]: Started GET "/projects/1/steps/update_ancestry?stepID=3&stepAncestry=1%2F2&position=2" for 76.118.180.235 at 2013-05-23 03:07:34 +0000
2013-05-23T03:07:34.975195+00:00 app[web.1]: Started GET "/projects/1/steps/update_ancestry?stepID=1&stepAncestry=0&position=0" for 76.118.180.235 at 2013-05-23 03:07:34 +0000
2013-05-23T03:07:34.999327+00:00 app[web.1]: Started GET "/projects/1/steps/update_ancestry?stepID=2&stepAncestry=1&position=1" for 76.118.180.235 at 2013-05-23 03:07:34 +0000

在本地服务器上运行的日志(删除了无关的调试消息):

Started PUT "/projects/86/steps/0" for 127.0.0.1 at 2013-05-22 23:08:57 -0400
Redirected to http://0.0.0.0:3000/projects/86/steps
Completed 302 Found in 26ms (ActiveRecord: 6.9ms)

Started GET "/projects/86/steps" for 127.0.0.1 at 2013-05-22 23:08:57 -0400

Started GET "/projects/86/steps/update_ancestry?stepID=463&stepAncestry=0&position=0" for 127.0.0.1 at 2013-05-22 23:08:57 -0400

Started GET "/projects/86/steps/update_ancestry?stepID=471&stepAncestry=463&position=1" for 127.0.0.1 at 2013-05-22 23:08:57 -0400

您可以在 Heroku 日志中看到,它没有进行重定向。

这里可能出了什么问题?Heroku 似乎没有给我任何错误消息...

steps_controller.rb:

class StepsController < ApplicationController

  before_filter :get_global_variables

  def update
    @step = @project.steps.find_by_position(params[:id])
    @step.images.each do |image|
      image.update_attributes(:saved => true)
    end

    respond_to do |format|
      if @step.update_attributes(params[:step])
        format.html { redirect_to project_steps_path(@project), :notice => 'Step was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render :action => "edit" }
        format.json { render :json => @step.errors, :status => :unprocessable_entity }
      end
    end
  end

private
  def get_global_variables
    @project = Project.find(params[:project_id])
    @steps = @project.steps.order("position")
    @numSteps = @steps.count
    @ancestry = @steps.pluck(:ancestry) # array of ancestry ids for all steps
    @allBranches # variable for storing the tree structure of the process map
    @user = @project.user # user who created the project
  end

end
4

0 回答 0