gitlab-org--gitlab-foss/app/models/environment.rb

17 lines
452 B
Ruby
Raw Normal View History

2016-06-10 17:36:54 -04:00
class Environment < ActiveRecord::Base
belongs_to :project, required: true, validate: true
2016-06-10 17:36:54 -04:00
has_many :deployments
2016-06-14 07:04:21 -04:00
validates :name,
presence: true,
2016-06-14 12:34:48 -04:00
uniqueness: { scope: :project_id },
2016-06-14 07:04:21 -04:00
length: { within: 0..255 },
format: { with: Gitlab::Regex.environment_name_regex,
message: Gitlab::Regex.environment_name_regex_message }
2016-06-10 17:36:54 -04:00
def last_deployment
deployments.last
end
end