From f55af3d75292e5296420f1d1cac7651e05d5deb8 Mon Sep 17 00:00:00 2001 From: lukaszreszke Date: Wed, 25 Sep 2024 14:16:59 +0200 Subject: [PATCH] Ignore stock level column of Product --- rails_application/app/models/product.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rails_application/app/models/product.rb b/rails_application/app/models/product.rb index f9443fb9..b13d6b13 100644 --- a/rails_application/app/models/product.rb +++ b/rails_application/app/models/product.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class Product < ApplicationRecord + self.ignored_columns = %w[stock_level] + validates :name, presence: true validates :price, numericality: { greater_than: 0 } validate :validate_vat_rate @@ -10,12 +12,6 @@ class Product < ApplicationRecord default_scope { where(latest: true) } - before_create :set_stock_level - - def set_stock_level - self.stock_level = 0 - end - def validate_vat_rate unless vat_rate.is_a?(Numeric) errors.add(:vat_rate, "is not a number")