Sha256: 507493edd9ae82dbd35a7b65db485ce5226757f25271d12be15f72165f4529b8

Contents?: true

Size: 816 Bytes

Versions: 3

Compression:

Stored size: 816 Bytes

Contents

module ForemanSalt
  class SaltEnvironment < ActiveRecord::Base
    include Taxonomix
    include Authorizable
    extend FriendlyId
    friendly_id :name

    before_destroy EnsureNotUsedBy.new(:hosts, :hostgroups)

    has_many :hosts, :class_name => '::Host::Managed'
    has_many :hostgroups, :class_name => '::Hostgroup'

    validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A[\w\d\.]+\z/, :message => N_('is alphanumeric and cannot contain spaces') }

    default_scope lambda {
      order('salt_environments.name')
    }

    scoped_search :on => :name, :complete_value => true
    scoped_search :in => :hostgroups, :on => :name, :complete_value => true, :rename => :hostgroup
    scoped_search :in => :hosts, :on => :name, :complete_value => true, :rename => :host
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_salt-2.0.2 app/models/foreman_salt/salt_environment.rb
foreman_salt-2.0.1 app/models/foreman_salt/salt_environment.rb
foreman_salt-2.0.0 app/models/foreman_salt/salt_environment.rb