From a3b7ff708ccefc764538b7045ff0b2dfcf010e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=B6hm?= Date: Mon, 9 Sep 2024 15:18:30 +0200 Subject: [PATCH] Force job costumer.firstname and lastname from costumer reference --- app/models/job.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/job.rb b/app/models/job.rb index b55005a..2ba8c57 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -15,7 +15,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 + before_validation :set_costumer_infos, unless: :created_by_operator?, on: :create # 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 @@ -165,7 +165,7 @@ class Job < ApplicationRecord 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? + self.costumer_firstname = costumer.firstname + self.costumer_lastname = costumer.lastname end end