simple_model 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,7 @@
1
1
  module SimpleModel
2
2
  module ErrorHelpers
3
+
4
+ attr_accessor :errors_count
3
5
 
4
6
  def errors?
5
7
  !self.errors.blank?
@@ -10,8 +12,8 @@ module SimpleModel
10
12
  #set defaults and overwrite
11
13
  options = {
12
14
  :failed_action => "saving",
13
- :id => 'errorExplanation',
14
- :classes => ''}.merge!(options)
15
+ :id => 'errorExplanation',
16
+ :classes => ''}.merge!(options)
15
17
 
16
18
  error_list = ""
17
19
 
@@ -34,12 +36,21 @@ module SimpleModel
34
36
  def create_error_list(key,value)
35
37
  error_items = ""
36
38
  if value.is_a?(Array)
37
- error_items << "<li><ul>#{key.to_s.titleize} #{puralize_errors_string(value)}:"
38
- value.each do |item|
39
- new_value = item.to_a[0]
40
- error_items << create_error_list(new_value[0],new_value[1])
39
+ if value.length == 1
40
+ self.errors_count = (self.errors_count.to_i + 1)
41
+ error_items << "<li>#{key.to_s.titleize} #{value[0]}<li>"
42
+ else
43
+ error_items << "<li><ul>#{key.to_s.titleize} errors:"
44
+ value.each do |item|
45
+ if item.is_a?(Hash)
46
+ new_value = item.to_a[0]
47
+ error_items << create_error_list(new_value[0],new_value[1])
48
+ else
49
+ error_items << "<li>#{key.to_s.titleize} #{item}</li>"
50
+ end
51
+ end
52
+ error_items << "</ul></li>"
41
53
  end
42
- error_items << "</ul></li>"
43
54
  elsif value.is_a?(Hash)
44
55
  error_items << "<li><ul>#{key.to_s.titleize} error:"
45
56
  error_items << create_error_list(value[0],value[1])
@@ -1,3 +1,3 @@
1
1
  module SimpleModel
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: simple_model
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.2
5
+ version: 0.2.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Joshua T Mckinney
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-08 00:00:00 -05:00
13
+ date: 2011-06-13 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency