better_error_message 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/better_error_message.rb +9 -3
- metadata +4 -4
data/lib/better_error_message.rb
CHANGED
@@ -5,14 +5,14 @@ module BetterErrorMessage
|
|
5
5
|
|
6
6
|
if fields.is_a?(Array)
|
7
7
|
fields.each do |field|
|
8
|
-
errors = model.errors
|
8
|
+
errors = model.errors[field]
|
9
9
|
next if errors.nil?
|
10
10
|
error = get_first_validation_error(errors)
|
11
11
|
return content_tag tag, error, :class => 'validation_error' unless error.blank?
|
12
12
|
end
|
13
13
|
else
|
14
14
|
field = fields
|
15
|
-
errors = model.errors
|
15
|
+
errors = model.errors[field]
|
16
16
|
error = get_first_validation_error(errors)
|
17
17
|
return content_tag tag, error, :class => 'validation_error' unless error.blank?
|
18
18
|
end
|
@@ -24,7 +24,13 @@ module BetterErrorMessage
|
|
24
24
|
|
25
25
|
def get_first_validation_error(errors)
|
26
26
|
if errors.is_a?(Array)
|
27
|
-
|
27
|
+
first = errors.first
|
28
|
+
|
29
|
+
if first.is_a?(Array)
|
30
|
+
first.first
|
31
|
+
else
|
32
|
+
first
|
33
|
+
end
|
28
34
|
else
|
29
35
|
return errors
|
30
36
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_error_message
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
version:
|
10
|
+
version: 3.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brent Greeff
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-11 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|