Avoid creating of duplicate articles. (Tests on article.name) Closes #10
This commit is contained in:
parent
aedfcae03b
commit
5e1fc73c29
1 changed files with 1 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue