gitlab-org--gitlab-foss/app/models/environment.rb
2016-06-14 13:51:12 +02:00

19 lines
458 B
Ruby

class Environment < ActiveRecord::Base
belongs_to :project
has_many :deployments
validates :name,
presence: true,
length: { within: 0..255 },
format: { with: Gitlab::Regex.environment_name_regex,
message: Gitlab::Regex.environment_name_regex_message }
validates_uniqueness_of :name, scope: :project_id
validates_associated :project
def last_deployment
deployments.last
end
end