environment.rb 458 字节
Newer Older
1 2 3 4 5
class Environment < ActiveRecord::Base
  belongs_to :project

  has_many :deployments

6 7 8 9 10
  validates :name,
            presence: true,
            length: { within: 0..255 },
            format: { with: Gitlab::Regex.environment_name_regex,
                      message: Gitlab::Regex.environment_name_regex_message }
11

12 13 14 15
  validates_uniqueness_of :name, scope: :project_id

  validates_associated :project

16 17 18 19
  def last_deployment
    deployments.last
  end
end