Whenever data are streamed by writing to response buffer from ActionController::Live
, the Apartment::Tenant.current
is reset back to the default tenant.
The project is setup with 2 tenants:
development
is the default tenant.test
is always used when accessing the site (refer toconfig/initializers/apartment.rb:102
)
Reproduction steps:
- Run server in local (example:
rails s
). - Go to path
/stream
(example:http://localhost:3000/stream
).
- Every lines should be
test
. Apartment::Tenant.current
keeps its current value.
- The first few lines show
test
tenant (first 11 lines on my machine). - The rest shows the default
development
tenant.