simple_model_translations 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@ module SimpleModelTranslations
9
9
  end
10
10
 
11
11
  def build_translation_for_locale(locale)
12
- translations.build(:locale => locale)
12
+ translations.build(:locale => locale, foreign_object_key => self)
13
13
  end
14
14
 
15
15
  def current_locale_for_translation
@@ -19,5 +19,10 @@ module SimpleModelTranslations
19
19
  def default_locale_for_translation
20
20
  I18n.default_locale
21
21
  end
22
+
23
+ private
24
+ def foreign_object_key
25
+ self.class.name.underscore.to_sym
26
+ end
22
27
  end
23
28
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleModelTranslations
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
@@ -28,4 +28,9 @@ end
28
28
 
29
29
  describe ArticleTranslation do
30
30
  it { should belong_to :article }
31
+
32
+ it 'always has an article' do
33
+ article = Article.new(:name => 'hello')
34
+ article.translations.first.article.should == article
35
+ end
31
36
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_model_translations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pavel Forkert
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-22 00:00:00 +03:00
18
+ date: 2010-10-23 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency