SqlBypass session store doesn't use ActiveRecord::Base connection

All the methods in ActiveRecord::SessionStore::SqlBypass use @@connection class var, instead of the homonym class method. This of course doesn't not guarantee that var isn't nil.

Try it by yourself: # config/initializers/session_store.rb ActionController::Base.session_store = :active_record_store ActiveRecord::SessionStore.session_class = ActiveRecord::SessionStore::SqlBypass

Then try to start the server and use sessions, it should raise a `NoMethodError`.

I created a patch for solving this issue, but not the whole problem. Since there aren't unit tests for `ActiveRecord` session stores, but only functional tests in `ActionPack`.

As you can see from the patch I replaced `@@connection` with `connection` only where covered by tests.

LH Ticket: #2383 SqlBypass session store doesn't use ActiveRecord::Base connection - Ruby on Rails - rails

Cheers, Luca