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

20 lines
458 B
Ruby
Raw Normal View History

2016-06-10 21:36:54 +00:00
class Environment < ActiveRecord::Base
belongs_to :project
has_many :deployments
2016-06-14 11:04:21 +00:00
validates :name,
presence: true,
length: { within: 0..255 },
format: { with: Gitlab::Regex.environment_name_regex,
message: Gitlab::Regex.environment_name_regex_message }
2016-06-10 21:36:54 +00:00
2016-06-14 11:51:12 +00:00
validates_uniqueness_of :name, scope: :project_id
validates_associated :project
2016-06-10 21:36:54 +00:00
def last_deployment
deployments.last
end
end