-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
This is not a bug with Mongoid at all, but just wanted to post a note for others to see.
When upgrading everything worked great in test/development but when I pushed to production I started seeing errors like this:
ActionDispatch::Session::SessionRestoreError (Session contains objects whose class definition isn't available.
Remember to require the classes for all objects kept in the session.
(Original exception: uninitialized constant BSON [NameError])
):
config/initializers/quiet_assets.rb:5:in `call_with_quiet_assets'
It turns out I was accidentally storing user id's in the session (cookie store) as:
- data: {"session_id"=>"...", "_csrf_token"=>"...", "user_id"=>BSON::ObjectId('4efdc6d7bedd320001000003')}
With the "BSON::ObjectId" text in there when I probably should have been to_s'ing it. Anyway, fix was easy enough. I changed one character in the config/initializers/secret_token.rb to reset all sessions. This allows new sessions to start being created with the new Moped format, which just to_s's it. This required all users to log in again, but worked.
Another solution might have been to stub out a BSON::ObjectId object in an initializer. Just wanted to create a record of this for future googlers.