【发布时间】:2013-12-23 16:14:16
【问题描述】:
所以我目前正在尝试使用我的 rails 应用程序和 gem 'rturk' 向 mturk 发布 HIT。整个过程顺利进行,除了当我打开 HIT 的亚马逊网址时,我的 rails 应用程序的表单没有显示在 iframe 中。它只是一个空白的白色 iframe。当我检查该页面的来源时,我可以清楚地看到其中包含 assignmentId、hitId 和 workerId 的正确链接。所以没有理由不显示它,对吧?这是要在 mturk 上显示的表单的一部分:
<%= form_for @results, :url => 'https://workersandbox.mturk.com/mturk/externalSubmit', html: {class: "takeTest takeScale"} do |f| %>
<%= hidden_field_tag 'assignmentId', @assignment_id %>
<%= hidden_field_tag 'hitId', @hit_id %>
<%= hidden_field_tag 'workerId', @worker_id %>
<%= f.submit("Submit Answers", class: 'btn btn-info') %>
这是我的控制器的一部分,使用 rturk 创建该表单作为 HIT:
#post to amazon mturk
RTurk.setup('MYKEY', 'MYOTHERKEY', :sandbox => true)
@hit = RTurk::Hit.create(:title => "#{@scale.title}") do |hit|
hit.max_assignments = 5
hit.description = 'post'
hit.question("https://my-rails-app.herokuapp.com/tests/scale/take/#{@scale.id}",
:frame_height => 500) # pixels for iframe
hit.reward = 0.05
hit.qualifications.add :approval_rate, { :gt => 80 }
end
redirect_to root_url, :notice => "posted at: #{@hit.url} !!!"
我想知道这是否与我的表单有关,或者是否与在 heroku 上托管有关?任何帮助将非常感激。顺便说一下,这是亚马逊上 iframe 的来源,以表明它应该都能正常工作:
<iframe height="500" scrolling="auto" frameborder="0" align="center" src="https://my-rails-app.herokuapp.com/tests/scale/take/7?assignmentId=2IBHSTLB3L0FPI5VSJAEMREVGFBIU0&hitId=2FC98JHSTLB3ZZBONH9OEJEJ4E6FRO&workerId=A1GHEKG3TRCQ5Y&turkSubmitTo=https%3A%2F%2Fworkersandbox.mturk.com" name="ExternalQuestionIFrame"></iframe>
谢谢!
【问题讨论】:
-
可能是因为我没有明确设置 SSL 吗?我引用了 https,如果我直接访问它,该链接就可以工作,所以我认为我不需要设置它。 Chrome 没有给我一个混合内容的警告,但我认为这可能是原因.. 我有什么事情吗?
-
我不认为我在做什么。 "SSL Endpoint 仅对自定义域有用。所有默认的 appname.herokuapp.com 域都已启用 SSL,并且只需使用 https 即可访问,例如 appname.herokuapp.com。"
-
我明白了!如果您像我一样经历十亿个头痛,请在遭受任何进一步痛苦之前检查一下:您的配置目录中的 application.rb。如果在您的 mturk HIT 页面上,javascript 控制台给出了 x-frame 错误,请将其添加到您的 application.rb config.action_dispatch.default_headers.clear Bam!我确信在我的故障排除过程中,我创建并解决了其他问题,但我希望这篇文章能帮助你!快乐的土耳其人。
-
确认 AlexTheGoodman 的评论也为我解决了这个问题。
标签: ruby-on-rails ruby http heroku mechanicalturk