has_safe_dates 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/has_safe_dates/core_ext.rb +3 -3
- data/lib/has_safe_dates/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1706f8d6cdbbd3d98e0fd78162be5d1a7e85c4f7
|
4
|
+
data.tar.gz: 5caf2882827bb4717238fa46fd553a18df1148e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bff2a615d7ce86c75221117ed9ee75067bc62bd88c2fbd871ed6ff0e44ab31619cb707d78e1284ec3940e1192b38cccd0e32f57db2dd28d1fe092d59cc0fe12
|
7
|
+
data.tar.gz: 2fc82cd206c61761404981f6a73b98c757dabeaae97d2b84f9e688f0c0949655f8f54e3a7aeb659b93c368ce58b9fd3096ed492a49aeecf7b5d136ccad2c95b0
|
@@ -29,9 +29,9 @@ module HasSafeDates
|
|
29
29
|
define_method "#{field.to_s}=" do |value|
|
30
30
|
if value.present?
|
31
31
|
value = Chronic.parse(value.to_s)
|
32
|
-
if value.blank? && self.class.has_safe_fields_config[self.class][:error_message].present?
|
32
|
+
if value.blank? && self.class.has_safe_fields_config[self.class.base_class][:error_message].present?
|
33
33
|
@safe_date_validation_errors ||= {}
|
34
|
-
@safe_date_validation_errors[field] = self.class.has_safe_fields_config[self.class][:error_message]
|
34
|
+
@safe_date_validation_errors[field] = self.class.has_safe_fields_config[self.class.base_class][:error_message]
|
35
35
|
end
|
36
36
|
end
|
37
37
|
super value
|
@@ -58,7 +58,7 @@ module HasSafeDates
|
|
58
58
|
# Overrides #read_date when has_safe_dates is enabled for the current field the multiparameter.
|
59
59
|
# Otherwise the original #read_date method is invoked.
|
60
60
|
def read_date
|
61
|
-
if ActiveRecord::Base.has_safe_fields_config[object.class] && ActiveRecord::Base.has_safe_fields_config[object.class][:fields].include?(name)
|
61
|
+
if ActiveRecord::Base.has_safe_fields_config[object.class.base_class] && ActiveRecord::Base.has_safe_fields_config[object.class.base_class][:fields].include?(name)
|
62
62
|
values.values_at(1,2,3).join("-") # Convert multiparameter parts into a Date string, e.g. "2011-4-23", return it, and allow CoreExt methods handle the result.
|
63
63
|
else
|
64
64
|
super # has_safe_dates is not enabled for the current field, so invoke the super method (original #read_date method).
|