Two changes were necessary to add support for Rails 5.
Rails 5 has a new rendering system that allows code such as xray's to render a view to a String from outside of a controller. This works using the new ApplicationController.render method. The old technique no longer works. To work without breaking compatibility with older Rails versions, we check to see if the new render method exists and use it if available; otherwise fall back to the previous technique.
Rails 5 uses streaming responses that are implicitly "committed" once the body of the response is read. Since xray must read the response in order to modify it (i.e. inject its JS), this causes the response to be considered committed, preventing changes to its headers. Hence we can no longer change the "Content-Length" header after modifying the body. We can still do so for older versions of Rails, but now we skip it if the response has the Rails 5 committed? flag.
Two changes were necessary to add support for Rails 5.
ApplicationController.render
method. The old technique no longer works. To work without breaking compatibility with older Rails versions, we check to see if the newrender
method exists and use it if available; otherwise fall back to the previous technique.committed?
flag.These changes were tested with Rails 5.0.0.rc1.
Fixes #63.