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")