views:

34

answers:

0

I was wondering if there was a way to trigger the after_save callback on an embedded_in object in Mongoid mapper.

Example:

i = Image.new(:file => file)
user.images << i
# => i.after_save should be triggered here

I'm aware that if I call i.save after words, it will fire, however really hard to remember to do that throughout my code.

Also, calling user.images.create(:file => file) is not an option, because I do a check to make sure the same file isn't uploaded twice.