Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- makes sure simple_record doesn't validate itself for uniqueness

  • Loading branch information...
commit a3b1338b30b3029d92ac1fd4747193214cedc4ee 1 parent 2099514
@superjustin superjustin authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/simple_record/validations.rb
View
4 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.")
Please sign in to comment.
Something went wrong with that request. Please try again.