I am trying to do a little test on rails ActiveController::Livewith a Puma server. I started the Puma server on rails s pumaand used it curl localhost:3000/messages/eventsfor testing. However, before the data was returned immediately, there was a long pause, which was the same as using WEBrick. So why is the Puma server not broadcasting the results?
class MessagesController < ApplicationController
include ActionController::Live
def index
@messages = Message.all
end
def create
@message = Message.create!(params[:message].permit(:content, :name))
end
def events
3.times do |n|
response.stream.write "#{n}...\n\n"
sleep 2
end
ensure
response.stream.close
end
end
source
share