From 6ce1b803602a57649f0bb2fd94b57e3686f9ddd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=B6hm?= Date: Thu, 3 Oct 2024 16:18:52 +0200 Subject: [PATCH] Fixed seed created_at column --- db/seeds.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index a52ddda..e8abf04 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -75,7 +75,7 @@ end updated_at = created_at + rand(4..44).minutes status_changed_at = updated_at end - job = Job.new(status:, privacy_policy: true, created_at: created_at) + job = Job.new(status:, privacy_policy: true) job.pdf = File.open(Rails.root.join('db/pdfs/', pdf)) student = students[rand(0..9)] job.customer = student @@ -84,6 +84,7 @@ end job.operator = operator if status != :open job.cashier = operator if status == :paid job.save! + job.update_column :created_at, created_at # write with update_column to avoid before_save action job.update_column :printed_at, printed_at # write with update_column to avoid before_save action job.update_column :status_changed_at, status_changed_at # write with update_column to avoid before_save action job.update_column :paid_at, paid_at if status == :paid # write with update_column to avoid before_save action @@ -109,7 +110,7 @@ end updated_at = created_at + rand(4..44).minutes status_changed_at = updated_at end - job = Job.new(status:, privacy_policy: true, created_at: created_at) + job = Job.new(status:, privacy_policy: true) job.pdf = File.open(Rails.root.join('db/pdfs/', pdf)) student = students[rand(0...9)] job.customer = student @@ -118,6 +119,7 @@ end job.operator = operator if status == :paid job.cashier = operator if status == :paid job.save! + job.update_column :created_at, created_at # write with update_column to avoid before_save action job.update_column :printed_at, printed_at # write with update_column to avoid before_save action job.update_column :status_changed_at, status_changed_at # write with update_column to avoid before_save action job.update_column :paid_at, paid_at if status == :paid # write with update_column to avoid before_save action