Ruby on rails rails 4实时流媒体阻止加载视图

Ruby on rails rails 4实时流媒体阻止加载视图,ruby-on-rails,ajax,streaming,server-sent-events,Ruby On Rails,Ajax,Streaming,Server Sent Events,在代码的最后,我想在同一页上呈现一个视图和一个数据流 class ManagerController < ApplicationController include ActionController::Live def index response.stream.write("Hello") response.stream.close end end 但问题是视图没有呈现,而是“hello”显示为html输出,如果我对这些响应代码进行注释,那么它就会呈现。如

在代码的最后,我想在同一页上呈现一个视图和一个数据流

class ManagerController < ApplicationController
  include ActionController::Live

  def index
    response.stream.write("Hello")
    response.stream.close
  end
end

但问题是视图没有呈现,而是“hello”显示为html输出,如果我对这些响应代码进行注释,那么它就会呈现。如何渲染视图并同时流式传输数据

由于它设置为响应文本,因此如果需要,它不会同时显示您的视图,然后使用
respond|format | format.html{}
请尝试它。我正在清除它…
respond|u to | format | do format.html{index.erb}format.text{response.stream写“Hello”response.stream.close}结束
由于第二个括号中的代码而导致语法错误。它呈现的内容显示您的日志?响应。标题['Content-Type']='text/event stream',然后写入
Hi!