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

destroy_all() doesn't work on embeds_many()

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.1.0
    • Affects Version/s: None
    • Component/s: None

      I have a User model containing the following embed declaration and method (other code excluded for clarity):

      embeds_many :temp_keys

      def update_temp_keys
      #self.temp_keys.destroy_all() # this doesn't work

      self.temp_keys.each do |key|
      self.reload
      key.delete
      end
      end

      As you can see I'd like to be using destroy_all() but I found it didn't actually alter the object in the database. The only way I could get Mongoid to persist the deletion was with the nasty each iterator above, which can't be good for speed.

      Let me know if there's any more information you need to help debug this, thanks.

            Assignee:
            durran Durran Jordan
            Reporter:
            sfcgeorge sfcgeorge
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: