Updated seed and model costumer association

This commit is contained in:
2024-08-28 21:33:22 +02:00
parent 4bbb5926b1
commit 017d6d25ae
4 changed files with 13 additions and 9 deletions

View File

@@ -16,6 +16,7 @@ class Job < ApplicationRecord
before_save :update_status_changed_at, if: :will_save_change_to_status?
before_save :set_cost_qm
before_save :calc_cost, if: :printed_pages_changes?
before_validation :set_costumer_infos
# TODO: works only when job is created. Should move analyzer to activestorage :
# https://discuss.rubyonrails.org/t/active-storage-in-production-lessons-learned-and-in-depth-look-at-how-it-works/83289
@@ -163,4 +164,9 @@ class Job < ApplicationRecord
calc_cost
save
end
def set_costumer_infos
self.costumer_firstname = costumer.firstname if self.costumer_firstname.nil?
self.costumer_lastname = costumer.lastname if self.costumer_lastname.nil?
end
end