app/models/naf/machine.rb in naf-2.1.9 vs app/models/naf/machine.rb in naf-2.1.10
- old
+ new
@@ -41,10 +41,11 @@
validates :thread_pool_size, numericality: {
only_integer: true,
greater_than: -2147483648,
less_than: 2147483647
}
+ before_save :check_presence_of_enabled_and_deleted
before_save :check_blank_values
#---------------------
# *** Associations ***
#+++++++++++++++++++++
@@ -257,9 +258,18 @@
def check_blank_values
self.short_name = nil if self.short_name.blank?
self.server_name = nil if self.server_name.blank?
self.server_note = nil if self.server_note.blank?
self.log_level = nil if self.log_level.blank?
+ end
+
+ def check_presence_of_enabled_and_deleted
+ if self.enabled && self.deleted
+ self.errors.add(:enabled, 'should not be true when deleted is true')
+ return false
+ end
+
+ return true
end
end
end