From 5e1fc73c296f4eb19fb41927bc33a7a9913d35c9 Mon Sep 17 00:00:00 2001 From: Benjamin Meichsner Date: Wed, 12 Aug 2009 12:33:07 +0200 Subject: [PATCH] Avoid creating of duplicate articles. (Tests on article.name) Closes #10 --- app/models/article.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/article.rb b/app/models/article.rb index de224304..25793807 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -42,6 +42,7 @@ class Article < ActiveRecord::Base validates_length_of :unit, :in => 2..15 validates_numericality_of :price, :unit_quantity, :greater_than => 0 validates_numericality_of :deposit, :tax + validates_uniqueness_of :name, :scope => [:supplier_id, :deleted_at] # Callbacks before_save :update_price_history