summaryrefslogtreecommitdiff
path: root/app/models/repository_language.rb
blob: e6867f905e2083d652a35adab7a9c244bd74fafb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

class RepositoryLanguage < ApplicationRecord
  belongs_to :project
  belongs_to :programming_language

  default_scope { includes(:programming_language) }

  validates :project, presence: true
  validates :share, inclusion: { in: 0..100, message: "The share of a lanuage is between 0 and 100" }
  validates :programming_language, uniqueness: { scope: :project_id }

  delegate :name, :color, to: :programming_language
end