ngauthier / tubesock

Websocket interface on Rack Hijack w/ Rails support
MIT License
620 stars 43 forks source link

Fix `env` deprecated in Rails 5.0 #55

Closed gosukiwi closed 6 years ago

gosukiwi commented 6 years ago

env is deprecated in Ralis 5.0 and removed in 5.1, this updates the code to use request.env instead: https://github.com/rails/rails/issues/23294

OlegSmelov commented 6 years ago

To support Rails 5.1, also replace

render text: nil, status: -1

with

render plain: nil, status: -1
gosukiwi commented 6 years ago

Good catch @OlegSmelov 👍 Done

cantino commented 6 years ago

It'd be great to see this get merged!

In the meantime, I don't use Tubesock::Hijack and instead define in my Controller:

private

def hijack
  sock = Tubesock.hijack(request.env)
  yield sock
  sock.onclose { ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord) }
  sock.listen
  render plain: nil, status: -1
end
ngauthier commented 6 years ago

If we can get the tests green I'm happy to merge it.