has_handle_fallback 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/has_handle_fallback.rb +5 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/has_handle_fallback.rb
CHANGED
@@ -81,7 +81,11 @@ module HasHandleFallback
|
|
81
81
|
end
|
82
82
|
|
83
83
|
# validates_uniqueness_of :handle, :case_sensitive => false, :allow_nil => true
|
84
|
-
if self.class.exists? [ "
|
84
|
+
if new_record? and self.class.exists? [ "LOWER(#{self.class.quoted_table_name}.`#{self.class.has_handle_fallback_options[:handle_column]}`) = ?", raw.downcase ]
|
85
|
+
errors.add self.class.has_handle_fallback_options[:handle_column], "isn't unique"
|
86
|
+
end
|
87
|
+
|
88
|
+
if !new_record? and self.class.exists? [ "#{self.class.quoted_table_name}.`#{self.class.primary_key}` <> ? AND LOWER(#{self.class.quoted_table_name}.`#{self.class.has_handle_fallback_options[:handle_column]}`) = ?", id, raw.downcase ]
|
85
89
|
errors.add self.class.has_handle_fallback_options[:handle_column], "isn't unique"
|
86
90
|
end
|
87
91
|
end
|