Class: Katello::HostCollectionHosts

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

Instance Method Summary collapse

Methods inherited from Model

#destroy!

Instance Method Details

#validate_max_hosts_not_exceededObject



10
11
12
13
14
15
16
17
18
19
# File 'app/models/katello/host_collection_hosts.rb', line 10

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,
                 _("You cannot have more than %{max_hosts} host(s) associated with host collection '%{host_collection}'.") %
                     { :max_hosts => host_collection.max_hosts, :host_collection => host_collection.name }
    end
  end
end