Remove validations in investment changelog entries

If we validate the presence of the old value and the new value, changes
in optional fields will not be stored if either the old value or the new
value are blank.
This commit is contained in:
Javi Martín
2019-11-02 00:36:56 +01:00
parent e08b516284
commit 6f4dc11dc4
2 changed files with 1 additions and 3 deletions

View File

@@ -413,7 +413,7 @@ class Budget
log.investment_id = self.id
log.new_value = self.send field
log.old_value = self.send "#{field}_was"
!log.save
log.save!
end
end
end

View File

@@ -5,8 +5,6 @@ class Budget::Investment::ChangeLog < ApplicationRecord
inverse_of: :budget_investment_change_logs,
required: false
validates :old_value, presence: true
validates :new_value, presence: true
validates :field, presence: true
scope :by_investment, ->(investment_id) { where(investment_id: investment_id) }