Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1701

after_save in observer, no fresh values within embedded object

      Hi,

      After fighting a bit with my specs, I realized the bug lived in my Observer, precisely in it's after_save method:

      def after_save(obj)
      binding.pry
      do_something if obj.status == "foo"
      end

      Basically, within debugger:

      One the one hand:

      obj.status
      #=> "bar"

      On the other hand:

      parent = obj._root.reload
      reloaded_obj = parent.children.where(:_id => obj.id).first
      reloaded_obj.status #=> "foo"

      I conclude, that my embedded obj doesn't bear it's updated values within my the{{ after_save}} method in the Observer.

      My configuration is:

      • rails '3.0.10'
      • mongoid '2.2.4'

            Assignee:
            Unassigned Unassigned
            Reporter:
            apneadiving apneadiving
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: