simple_model 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_model.rb +1 -1
- data/lib/simple_model/error_helpers.rb +18 -19
- data/lib/simple_model/version.rb +1 -1
- metadata +2 -2
data/lib/simple_model.rb
CHANGED
@@ -3,7 +3,7 @@ module SimpleModel
|
|
3
3
|
autoload :ExtendCore, "simple_model/extend_core"
|
4
4
|
autoload :Attributes, "simple_model/attributes"
|
5
5
|
autoload :Errors, "simple_model/errors"
|
6
|
-
|
6
|
+
autoload :ErrorHelpers, "simple_model/error_helpers"
|
7
7
|
autoload :Validation, "simple_model/validation"
|
8
8
|
|
9
9
|
# require active_model if available
|
@@ -1,26 +1,25 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module SimpleModel
|
2
|
+
module ErrorHelpers
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
!self.errors.nil? && !self.errors.empty?
|
8
|
-
end
|
4
|
+
def errors?
|
5
|
+
!self.errors.nil? && !self.errors.empty?
|
6
|
+
end
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
def errors_for_flash
|
9
|
+
error_string = "<div id='smErrorExplanation'>#{self.errors.count} errors prevented saving.</div>"
|
10
|
+
self.errors.full_messages.each do |m|
|
11
|
+
error_string << "<div>#{m}</div>"
|
12
|
+
end
|
13
|
+
error_string
|
14
14
|
end
|
15
|
-
error_string
|
16
|
-
end
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
def errors_to_s
|
17
|
+
error_string = ""
|
18
|
+
self.errors.full_messages.each do |m|
|
19
|
+
error_string << "#{m} "
|
20
|
+
end
|
21
|
+
error_string
|
22
22
|
end
|
23
|
-
error_string
|
24
|
-
end
|
25
23
|
|
24
|
+
end
|
26
25
|
end
|
data/lib/simple_model/version.rb
CHANGED