Determine what ids were removed from array in Rails after_save callback?
I am trying to figure out how i can tell what has changed in an array in the after save callback. Here is an example of code i am using:

    class User < ActiveRecord::Base
      has_many :user_maps, :dependent => :destroy
      has_many :subusers, :through => :user_maps, :dependent => :destroy
    
      after_save :remove_subusers
    
      def remove_subusers
        if self.subuser_ids_were != self.subuser_ids
          leftover = self.subuser_ids_were - self.subuser_ids
          
          leftover.each do |subuser|
            subuser.destroy
          end
        end
      end
    end
    
    class UserMap < ActiveRecord::Base
      belongs_to :user
      belongs_to :subuser, :class_name => "User"
    end

I am removing the subusers with the after_save callback because i could not get the dependent destroy feature to work through user_maps. Does anyone have any ideas on a way to do this?

Thanks!
Determine what ids were removed from array in Rails after_save callback?
===

I am trying to figure out how i can tell what has changed in an array in the after save callback. Here is an example of code i am using:

    class User < ActiveRecord::Base
      has_many :user_maps, :dependent => :destroy
      has_many :subusers, :through => :user_maps, :dependent => :destroy
    
      after_save :remove_subusers
    
      def remove_subusers
        if self.subuser_ids_were != self.subuser_ids
          leftover = self.subuser_ids_were - self.subuser_ids
          
          leftover.each do |subuser|
            subuser.destroy
          end
        end
      end
    end
    
    class UserMap < ActiveRecord::Base
      belongs_to :user
      belongs_to :subuser, :class_name => "User"
    end

I am removing the subusers with the after_save callback because i could not get the dependent destroy feature to work through user_maps. Does anyone have any ideas on a way to do this?

Thanks!