diff options
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r-- | app/models/environment.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb index 558963c98c4..125218ea21d 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -5,6 +5,7 @@ class Environment < ApplicationRecord include ReactiveCaching include FastDestroyAll::Helpers include Presentable + include NullifyIfBlank self.reactive_cache_refresh_interval = 1.minute self.reactive_cache_lifetime = 55.seconds @@ -14,6 +15,7 @@ class Environment < ApplicationRecord belongs_to :project, required: true use_fast_destroy :all_deployments + nullify_if_blank :external_url has_many :all_deployments, class_name: 'Deployment' has_many :deployments, -> { visible } @@ -33,7 +35,6 @@ class Environment < ApplicationRecord has_one :upcoming_deployment, -> { running.distinct_on_environment }, class_name: 'Deployment', inverse_of: :environment has_one :latest_opened_most_severe_alert, -> { order_severity_with_open_prometheus_alert }, class_name: 'AlertManagement::Alert', inverse_of: :environment - before_validation :nullify_external_url before_validation :generate_slug, if: ->(env) { env.slug.blank? } before_save :set_environment_type @@ -230,10 +231,6 @@ class Environment < ApplicationRecord ref.to_s == last_deployment.try(:ref) end - def nullify_external_url - self.external_url = nil if self.external_url.blank? - end - def set_environment_type names = name.split('/') |