Avoid creating of duplicate articles. (Tests on article.name) Closes #10

This commit is contained in:
Benjamin Meichsner 2009-08-12 12:33:07 +02:00
parent aedfcae03b
commit 5e1fc73c29

View file

@ -42,6 +42,7 @@ class Article < ActiveRecord::Base
validates_length_of :unit, :in => 2..15 validates_length_of :unit, :in => 2..15
validates_numericality_of :price, :unit_quantity, :greater_than => 0 validates_numericality_of :price, :unit_quantity, :greater_than => 0
validates_numericality_of :deposit, :tax validates_numericality_of :deposit, :tax
validates_uniqueness_of :name, :scope => [:supplier_id, :deleted_at]
# Callbacks # Callbacks
before_save :update_price_history before_save :update_price_history