acts_as_translatable 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@ class ActiveRecord::Base
2
2
  def self.acts_as_translatable_on(*fields)
3
3
  eval "class ::#{name}
4
4
  after_save :save_translations
5
+ after_destroy :destroy_record_translations
5
6
 
6
7
  def translations
7
8
  unless @translations
@@ -19,9 +20,9 @@ class ActiveRecord::Base
19
20
  end
20
21
 
21
22
  def save_translations
22
- # delete all previous record translations
23
- record_translations.destroy_all
24
-
23
+ # delete all previous translations of this record
24
+ destroy_record_translations
25
+
25
26
  # loop through updated translations
26
27
  translations.each_pair do |locale, fields|
27
28
  fields.each_pair do |field, content|
@@ -30,6 +31,11 @@ class ActiveRecord::Base
30
31
  end
31
32
  end
32
33
  end
34
+
35
+ def destroy_record_translations
36
+ # delete all translations of this record
37
+ record_translations.destroy_all
38
+ end
33
39
  end"
34
40
  fields.each do |field|
35
41
  eval "class ::#{name}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_translatable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lasse Bunk