You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is exhibited when you have an instance of MyMongoid and try to call publish! on it. The status field is changed to published, but the model is not saved. If you try to save it manually (with save or save!), the status is changed back to draft when you reload or re-query the object from the database.
Fixing it was easy, we just renamed the field to :status and left the alias out. Not ideal, but did take a lot of debugging to figure out what was causing the behaviour explained above. I also reason that we could have just changed the state machine to use the real field name (e.g. state_machine :st ...) and it would have worked, though that would muddy up our domain and hide our intentions behind the abbreviation.
If I get some free time soon, I'll try to work up a patch, but right now I have people to see, fat to chew, and a feature to ship.
We defined our Mongoid field with an alias. Here is a simple example class to illustrate the issue:
The issue is exhibited when you have an instance of
MyMongoid
and try to callpublish!
on it. The status field is changed topublished
, but the model is not saved. If you try to save it manually (withsave
orsave!
), the status is changed back todraft
when you reload or re-query the object from the database.Fixing it was easy, we just renamed the field to
:status
and left the alias out. Not ideal, but did take a lot of debugging to figure out what was causing the behaviour explained above. I also reason that we could have just changed the state machine to use the real field name (e.g.state_machine :st ...
) and it would have worked, though that would muddy up our domain and hide our intentions behind the abbreviation.If I get some free time soon, I'll try to work up a patch, but right now I have people to see, fat to chew, and a feature to ship.
More info on the field aliasing feature: http://mongoid.org/en/mongoid/docs/documents.html#field_aliasing (you may need to scroll up a little, the hash anchor was a little screwy for me)
Cheers, and thanks for an otherwise super solid library.
The text was updated successfully, but these errors were encountered: