Class: Katello::HostCollectionHosts

Inherits:
Model
  • Object
show all
Defined in:
app/models/katello/host_collection_hosts.rb

Instance Method Summary collapse

Instance Method Details

#validate_max_hosts_not_exceededObject



8
9
10
11
12
13
14
15
# File 'app/models/katello/host_collection_hosts.rb', line 8

def validate_max_hosts_not_exceeded
  if new_record? && self.host_collection_id
    host_collection = HostCollection.find(self.host_collection_id)
    if host_collection && !host_collection.unlimited_hosts && (host_collection.hosts.size >= host_collection.max_hosts)
      errors.add(:base, host_collection.max_hosts_exceeded_message)
    end
  end
end