diff options
author | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-07-26 15:19:37 +0300 |
---|---|---|
committer | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-07-29 14:54:45 +0300 |
commit | 76e9b68439510af5c783a81b93944f1c8d96d150 (patch) | |
tree | 62f4dde6c0caa56aa9ebbbdd31df9a215767dc87 /app/models/environment.rb | |
parent | 84cd2120952e7ee4095cb4b5d7c959f2c11610c5 (diff) |
Incorporate feedback
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r-- | app/models/environment.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb index 9eff0fdab03..baed106e8c8 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -3,6 +3,8 @@ class Environment < ActiveRecord::Base has_many :deployments + before_validation :nullify_external_url + validates :name, presence: true, uniqueness: { scope: :project_id }, @@ -12,9 +14,15 @@ class Environment < ActiveRecord::Base validates :external_url, uniqueness: { scope: :project_id }, - length: { maximum: 255 } + length: { maximum: 255 }, + allow_nil: true, + addressable_url: true def last_deployment deployments.last end + + def nullify_external_url + self.external_url = nil if self.external_url.blank? + end end |