Skip to content

Commit

Permalink
Ignore stock level column of Product
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszreszke committed Oct 10, 2024
1 parent b61c068 commit efcf788
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions rails_application/app/models/product.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
Expand Down

0 comments on commit efcf788

Please sign in to comment.