localizable_db 1.0.4 → 1.0.5
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.
- checksums.yaml +4 -4
- data/lib/localizable_db/localizable.rb +12 -8
- data/lib/localizable_db/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfa24ac30c6f360b07598b83926ce5b85e698b2a4f48d07043106dd9d44d6665
|
4
|
+
data.tar.gz: 32e43bbc87c5d14d97b95b1d8702ed74ed0e755fe70bcb547baa6233e83aa92a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1dc64f5544f611371e10907759d2a583467aff752169c757601c0682cd8d814359a407280a287a4527e5e908c8bbaaa84350735f36a9aa185d7dd6f877f51f9
|
7
|
+
data.tar.gz: bffe0f2dce87ca91e100f06cbb104d301203095c59025b41723393f08ba42f1222dcfc034d6a0a8c8c4b7823f6ec12bec870e8eaba556d421678f7aa7a3bcf2c
|
@@ -16,16 +16,20 @@ module LocalizableDb
|
|
16
16
|
aux_object.send(:"#{attribute}=", language_values[attribute.to_sym])
|
17
17
|
end
|
18
18
|
aux_object.localizable_object_id = self.id
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
aux_object._validators.delete(validator)
|
19
|
+
not_localized_attributes = (self.attribute_names.map{|x| x.to_sym}-self.class.localized_attributes.map{|x| x.to_sym})
|
20
|
+
not_localized_attributes.each do |attribute|
|
21
|
+
aux_object.class_eval{ attr_accessor :"#{attribute}"}
|
23
22
|
end
|
24
|
-
aux_object.
|
25
|
-
|
23
|
+
if !aux_object.valid?
|
24
|
+
not_localized_attributes.each{|attribute| aux_object.errors.delete(attribute) }
|
25
|
+
end
|
26
|
+
aux_object.save(validate: false) if aux_object.errors.empty?
|
27
|
+
not_localized_attributes.each do |attribute|
|
28
|
+
aux_object.class_eval do
|
29
|
+
undef :"#{attribute}"
|
30
|
+
undef :"#{attribute}="
|
31
|
+
end
|
26
32
|
end
|
27
|
-
aux_object.save
|
28
|
-
aux_object._validators.merge(validators_copy)
|
29
33
|
aux_object.errors.messages.each do |err_key,err_message|
|
30
34
|
self.errors.add("#{language_key}_#{err_key}", err_message)
|
31
35
|
end if aux_object.errors.any?
|