aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/referential_suite.rb
blob: 93c2c3f36a3401c9fbbbb12ddc8f2bb5cc264a82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class ReferentialSuite < ActiveRecord::Base
  belongs_to :new, class_name: 'Referential'
  validate def validate_consistent_new
    return true if new_id.nil?
    return true if new.referential_suite_id == id
    errors.add(:inconsistent_new,
               I18n.t('referential_suites.errors.inconsistent_new', name: new.name))
  end

  belongs_to :current, class_name: 'Referential'
  validate def validate_consistent_current
    return true if current_id.nil?
    return true if current.referential_suite_id == id
    errors.add(:inconsistent_current,
               I18n.t('referential_suites.errors.inconsistent_current', name: current.name))
  end

  has_many :referentials
end