【发布时间】:2015-01-28 14:03:30
【问题描述】:
我希望在不重新加载服务器的情况下将数据库中的更改反映在页面上。
控制器
class ProductController < ApplicationController
include ActionController::Live
def index
@product = Product.available
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
sse.write @product
ensure
sse.close
end
end
查看
<p><%= @product[:price] %></p>
我正在使用彪马。
当我在数据库中更新产品时,更改不会反映在网页上。
我错过了什么?
【问题讨论】:
标签: ruby-on-rails multithreading concurrency server-sent-events puma