|  |  | @@ -16,7 +16,7 @@ class Service < ActiveRecord::Base | 
            
            
              | 16 | 16 |    scope :by_name, lambda { |dir = 'desc'| order("services.name #{dir}") } | 
            
            
              | 17 | 17 |   | 
            
            
              | 18 | 18 |    def disable_agents(conditions = {}) | 
            
            
              | 19 |  | -    agents.where.not(conditions).each do |agent| | 
            
            
              |  | 19 | +    agents.where.not(conditions[:where_not] || {}).each do |agent| | 
            
            
              | 20 | 20 |        agent.service_id = nil | 
            
            
              | 21 | 21 |        agent.disabled = true | 
            
            
              | 22 | 22 |        agent.save!(validate: false) | 
            
            
            
            
              |  |  | @@ -24,7 +24,7 @@ class Service < ActiveRecord::Base | 
            
            
              | 24 | 24 |    end | 
            
            
              | 25 | 25 |   | 
            
            
              | 26 | 26 |    def toggle_availability! | 
            
            
              | 27 |  | -    disable_agents(user_id: self.user_id) if global | 
            
            
              |  | 27 | +    disable_agents(where_not: {user_id: self.user_id}) if global | 
            
            
              | 28 | 28 |      self.global = !self.global | 
            
            
              | 29 | 29 |      self.save! | 
            
            
              | 30 | 30 |    end |