-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
Because Mongoid updates the attributes directly from the DB:
https://github.com/mongoid/mongoid/blob/master/lib/mongoid/document.rb#L149
Rather than via the model class like ActiveRecord does:
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/persistence.rb#L240
I've got model logic that uses callbacks to cast values in a Hash between Time (for MongoDB) and Date (for my app), but to get it to run I need to do:
obj.reload
obj.run_callbacks :initialize
This is a bigger pain when other things call reload under the hood (e.g. machinist_mongo) expecting it to run callbacks, then give me back an object that behaves unexpectedly.