-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
Using mongoid-3.1.5
To put some routes aside, we are using becomes like = simple_form_for [@contact.becomes(Contact), @assignment], wrapper: :default do |f| while contact normally is of type Person or Company what is derived from Contact
After this we render a menu that calls something like current_user.contact_fullname while contact_fullname is a delegate of the method fullname declared only in the derived classes Person and Company.
Now we are getting an error, no method found for Contact#fullname. In my honest opinion, becomes have not to alter the instance of the current_user but obviously it does. I suspect IdentityMap.set(became) that caches something. So I am not such familiar with the core functionality of Mongoid and its philosophy but I call this a bug. I am right? And should I take care to solve this problem?
I suggest to simply not cache when calling becomes, hoping it is the guilty one because I didn't test it without IdentityMap.set... at the moment.
My key argument is that when I call becomes I expect returning a document without changing the original document.