def index
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
begin
Test.on_change do |id|
test = Test.find(id)
t = render_to_string(partial: 'stats', formats: [:html], locals: {test: test}).gsub("\n","")
sse.write(t)
end
rescue IOError
# Client Disconnected
ensure
sse.close
end
render nothing: true
end
reload
получает данные из кэша, если они там лежат. Test.uncached do
Test.find(id)
end