3
我希望數據庫中的更改反映在頁面上而不需要重新加載服務器。ActionController :: Live - SSE在Rails中
控制器
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>
我使用彪馬。
當我更新數據庫中的產品時,更改未反映在網頁上。
我錯過了什麼?
Redis目前不在我的堆棧中。有什麼特別的配置,我必須投入到這個地方工作? @KPheasey – softcode 2015-01-27 01:38:17
它看起來像淋浴創建一條路線--- get'/ stream',到:'shower/stream#index'---這個流是否流入/流?如果是這樣,在訪問該頁面時,Rails抱怨:「無法修改冷凍哈希」@KPheasey – softcode 2015-01-27 21:53:39