diff options
Diffstat (limited to 'app/models/clean_up.rb')
| -rw-r--r-- | app/models/clean_up.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/app/models/clean_up.rb b/app/models/clean_up.rb index ca4f6312b..0f73e07b2 100644 --- a/app/models/clean_up.rb +++ b/app/models/clean_up.rb @@ -12,6 +12,10 @@ class CleanUp < ApplicationModel validate :end_date_must_be_greater_that_begin_date after_commit :perform_cleanup, :on => :create + scope :for_referential, ->(referential) do + where(referential_id: referential.id) + end + def end_date_must_be_greater_that_begin_date if self.end_date && self.date_type == 'between' && self.begin_date >= self.end_date errors.add(:base, I18n.t('activerecord.errors.models.clean_up.invalid_period')) |
