diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/models/referential.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb index c7b52ddf8..04cdf986d 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -1,4 +1,3 @@ -# coding: utf-8 class Referential < ActiveRecord::Base include DataFormatEnumerations @@ -28,6 +27,15 @@ class Referential < ActiveRecord::Base belongs_to :organisation validates_presence_of :organisation + validate def validate_consistent_organisation + return true if workbench_id.nil? + ids = [workbench.organisation_id, organisation_id] + return true if ids.first == ids.last + errors.add(:inconsistent_organisation, + I18n.t('referentials.errors.inconsistent_organisation', + indirect_name: workbench.organisation.name, + direct_name: organisation.name)) + end belongs_to :line_referential validates_presence_of :line_referential |
