0

我从外部表单将信息发送到 Heroku 上的 Rails 应用程序 - 它运行良好,现在突然停止 - 不知道为什么 [我确实添加了 unicorn 并更改为 ruby​​ 1.9.3,但我认为这些不是问题。] 我将代码简化为基础,它仍然会停止应用程序。

任何建议,将不胜感激。谢谢!

这是外部形式:

<form action="https://pacific-forest-7999.herokuapp.com/exams" method="post" \>
<input type="submit" name="Submit" value="">
</form>

我将创建操作的exams_controller.rb 简化为:

def create
 @exam = Exam.new(params[:exam])

 respond_to do |format|
  if @exam.save
    format.html { redirect_to @exam, notice: 'Exam was successfully created.' }
    format.json { render json: @exam, status: :created, location: @exam }
  else
    format.html { render action: "new" }
    format.json { render json: @exam.errors, status: :unprocessable_entity }
  end
 end
end

这是失败时的一些日志[虽然我没有看到那里列出的考试控制器操作...]

» 11:20:47.516  2013-10-11 18:18:56.319768+00:00 app web.1     - - Started GET "/" for 184.73.237.85/ec2-184-73-237-85.compute-1.amazonaws.com at 2013-10-11 18:18:56 +0000
» 11:20:47.516  2013-10-11 18:18:56.323627+00:00 app web.1     - - Processing by PatientsController#index as */*
» 11:20:47.516  2013-10-11 18:18:56.331746+00:00 app web.1     - -   Rendered patients/index.html.erb within layouts/application (0.2ms)
» 11:20:47.516  2013-10-11 18:18:56.333623+00:00 app web.1     - -   Rendered layouts/_shim.html.erb (0.0ms)
» 11:20:47.516  2013-10-11 18:18:56.341719+00:00 app web.1     - -   Rendered layouts/_footer.html.erb (0.1ms)
» 11:20:47.516  2013-10-11 18:18:56.342156+00:00 app web.1     - - Completed 200 OK in 12ms (Views: 11.5ms | ActiveRecord: 0.0ms)
» 11:20:53.531  2013-10-11 18:20:53.475922+00:00 heroku router - - at=info method=HEAD path=/ host=pacific-forest-7999.herokuapp.com fwd="50.31.164.139/NX" dyno=web.1 connect=1ms service=25ms status=200 bytes=0
4

1 回答 1

1

您可以在控制器中关闭 CSFR 检查

def ExamsController < ApplicationController
  protect_from_forgery :except => :create 
于 2013-10-11T20:23:31.443 回答