-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
(I'm a quite new user and contributor of Mongoid. Hello everyone and thanks for the awesome work! :+1
In add_counter_cache_callbacks method, the only callbacks that are added are after_create and before_destroy.
What about when the association is updated?
In my case, I have 2 models Company and User:
class User include Mongoid::Document belongs_to :company, counter_cache: true end class Company include Mongoid::Document field :users_count, type: Integer, default: 0 has_many :users end
When I update a User to change his Company, the users_count is not updated. The counter for the former Company is not decremented, and the counter for the new Company is not incremented.
Maybe I missed something, but shouldn't add_counter_cache_callbacks also implement before_update and after_update? or should it rather implement the new Relation Callbacks?