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
Alize puts "from" callbacks in before_save. Per Rails callbacksbefore_save is fired before before_create. Furthermore, since alize_from is above the before_create block in ClassB, it would add its callback too early even if it was before_save. Here are some options to work around this.
Option 1 - manually call denormalize_from_all
before_create do
self.class_a = ClassA.create(text: 'Hello')
self.denormalize_from_all
end
Option 2 - Use before_save, and put alize_fromafter the before_save callback
class ClassB
include Mongoid::Document
include Mongoid::Alize
belongs_to :class_a
before_save do
self.class_a = ClassA.create(text: 'Hello')
end
alize_from :class_a, :text
end
I have two classes:
If I do this, alize don't work:
When Alize is executed ?
The text was updated successfully, but these errors were encountered: