2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
class RepositoryLanguage < ApplicationRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
belongs_to :project
|
|
|
|
belongs_to :programming_language
|
|
|
|
|
|
|
|
default_scope { includes(:programming_language) }
|
|
|
|
|
|
|
|
validates :project, presence: true
|
2019-12-21 20:55:43 +05:30
|
|
|
validates :share, inclusion: { in: 0..100, message: "The share of a language is between 0 and 100" }
|
2018-11-18 11:00:15 +05:30
|
|
|
validates :programming_language, uniqueness: { scope: :project_id }
|
|
|
|
|
|
|
|
delegate :name, :color, to: :programming_language
|
|
|
|
end
|