Permalink
Browse files

Validates uniqueness of does not care about ids

  • Loading branch information...
1 parent 61fb666 commit 0799262036cc1d4df4176ca4b445e3bc8db06b8f @durran durran committed Jan 20, 2010
Showing with 5 additions and 2 deletions.
  1. +3 −0 lib/validatable.rb
  2. +2 −2 lib/validations/validates_uniqueness_of.rb
View
@@ -1,5 +1,8 @@
require 'forwardable'
require 'rubygems'
+
+gem "activesupport", ">= 2.2.2", "< 3.0.pre"
+
require 'active_support'
dir = File.expand_path(File.dirname(__FILE__))
@@ -8,11 +8,11 @@ def valid?(instance)
conditions.merge!(scope => instance.send(scope))
end
doc = instance.class.first(:conditions => conditions)
- doc.nil? || instance.id == doc.id
+ doc.nil?
end
def message(instance)
super || "must be unique"
end
end
-end
+end

0 comments on commit 0799262

Please sign in to comment.