Permalink
Browse files

- makes sure simple_record doesn't validate itself for uniqueness

  • Loading branch information...
1 parent 2099514 commit a3b1338b30b3029d92ac1fd4747193214cedc4ee @superjustin superjustin committed May 17, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/simple_record/validations.rb
@@ -71,7 +71,9 @@ def validate_uniques
val = self.send(k)
puts 'val=' + val.inspect
if val
- ret = self.class.find(:first, :conditions=>["#{k}=?", val])
+ conditions = new_record? ? ["#{k}=?", val] : ["#{k}=? AND id != ?", val, self.id]
+
+ ret = self.class.find(:first, :conditions=>conditions)
puts 'ret=' + ret.inspect
if ret
errors.add(k, "must be unique.")

0 comments on commit a3b1338

Please sign in to comment.