acts_as_translatable 0.2.3 → 0.2.4

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.
@@ -8,6 +8,7 @@ class ActiveRecord::Base
8
8
  after_initialize :translations
9
9
  after_save :save_translations
10
10
  after_destroy :destroy_record_translations
11
+ has_many :record_translations, :foreign_key => :translatable_id, :conditions => { :translatable_type => '#{name}'}
11
12
 
12
13
  def self.translatable_fields
13
14
  [#{field_symbols}]
@@ -27,10 +28,6 @@ class ActiveRecord::Base
27
28
  @translations
28
29
  end
29
30
 
30
- def record_translations
31
- @record_translations ||= RecordTranslation.where(:translatable_id => id, :translatable_type => self.class.name)
32
- end
33
-
34
31
  def save_translations
35
32
  # delete all previous translations of this record
36
33
  destroy_record_translations
@@ -39,7 +36,7 @@ class ActiveRecord::Base
39
36
  translations.each_pair do |locale, fields|
40
37
  fields.each_pair do |field, content|
41
38
  # create translation record
42
- RecordTranslation.create :translatable_id => id, :translatable_type => self.class.name, :translatable_field => field, :locale => locale.to_s, :content => content unless content.blank?
39
+ record_translations.create :translatable_field => field, :locale => locale.to_s, :content => content unless content.blank?
43
40
  end
44
41
  end
45
42
  end
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: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lasse Bunk
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-20 00:00:00 Z
18
+ date: 2012-05-22 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Ruby on Rails plugin for easy translation of database fields.