validates_existence 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/rails2.rb +6 -2
  2. data/lib/rails3.rb +7 -3
  3. metadata +3 -3
data/lib/rails2.rb CHANGED
@@ -26,11 +26,14 @@ module Perfectline
26
26
  end
27
27
 
28
28
  if target_class.nil? or !target_class.exists?(value)
29
- record.errors.add(attribute, options[:message], :default => "does not exist")
29
+ errors = [attribute]
30
30
 
31
31
  # add the error on both :relation and :relation_id
32
32
  if options[:both]
33
33
  normalized = attribute.to_s.ends_with?("_id") ? normalized : "#{attribute}_id"
34
+ errors.push(normalized) unless errors.include? attribute
35
+ end
36
+ errors.each do | error |
34
37
  record.errors.add(normalized, options[:message], :default => "does not exist")
35
38
  end
36
39
  end
@@ -38,4 +41,5 @@ module Perfectline
38
41
  end
39
42
  end
40
43
  end
41
- end
44
+ end
45
+
data/lib/rails3.rb CHANGED
@@ -35,12 +35,15 @@ module Perfectline
35
35
  end
36
36
 
37
37
  if value.nil? or target_class.nil? or !target_class.exists?(value)
38
- record.errors.add(attribute, options[:message], :message => "does not exist")
38
+ errors = [attribute]
39
39
 
40
40
  # add the error on both :relation and :relation_id
41
41
  if options[:both]
42
42
  normalized = attribute.to_s.ends_with?("_id") ? normalized : "#{attribute}_id"
43
- record.errors.add(normalized, options[:message], :message => "does not exist")
43
+ errors.push(normalized) unless errors.include? attribute
44
+ end
45
+ errors.each do | error |
46
+ record.errors.add(normalized, options[:message], :default => "does not exist")
44
47
  end
45
48
  end
46
49
  end
@@ -54,4 +57,5 @@ module Perfectline
54
57
 
55
58
  end
56
59
  end
57
- end
60
+ end
61
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 4
9
- version: 0.5.4
8
+ - 5
9
+ version: 0.5.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tanel Suurhans
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-02 00:00:00 +03:00
18
+ date: 2010-12-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21