simple_model_translations 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -6,15 +6,16 @@ It borrows some things from globalize3[http://github.com/svenfuchs/globalize3] a
6
6
  == Basic Usage
7
7
 
8
8
  For example, you are dealing with a website for some magazine, and you want your articles to be translated.
9
- So, you'll need the following models to achieve this behaviour:
10
-
11
- class Article < ActiveRecord::Base
12
- translates :name, :content
13
- end
9
+ So, you'll need the following models to achieve this behaviour
10
+ (warning: ArticleTranslation should be defined before Article, or Rails should be able to autoload it):
14
11
 
15
12
  class ArticleTranslation < ActiveRecord::Base
16
13
  translation_for :article
17
14
  end
15
+
16
+ class Article < ActiveRecord::Base
17
+ translates :name, :content
18
+ end
18
19
 
19
20
  or, if you are not going to add some additional behavior to translation class (for example, validations),
20
21
  you can use translation class, created for you by default:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -50,7 +50,7 @@ module SimpleModelTranslations
50
50
  include SimpleModelTranslations::Attributes
51
51
  extend SimpleModelTranslations::ClassMethods
52
52
 
53
- has_many :translations, :class_name => translation_class_name, :dependent => :destroy, :autosave => true
53
+ has_many :translations, :class_name => translation_class.name, :dependent => :destroy, :autosave => true
54
54
 
55
55
  if options[:accepts_nested_attributes]
56
56
  accepts_nested_attributes_for :translations, :allow_destroy => true
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{simple_model_translations}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Pavel Forkert"]
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  "lib/simple_model_translations/validations.rb",
33
33
  "simple_model_translations.gemspec",
34
34
  "spec/attributes_spec.rb",
35
+ "spec/auto_generated_translation_classes_spec.rb",
35
36
  "spec/class_methods_spec.rb",
36
37
  "spec/data/models.rb",
37
38
  "spec/data/schema.rb",
@@ -1,15 +1,17 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe Tag do
4
- it "should create translation class automatically if it doesn't exists" do
5
- Tag.translation_class.should_not be_nil
6
- Tag.translation_class.table_name.should == 'tag_translations'
7
- end
8
-
9
4
  it "should be" do
10
- tag = Tag.new(:locale => :en, :name => 'hello')
5
+ tag = Tag.create!(:locale => :en, :name => 'hello')
6
+ tag.name = 'hello, ukraine!'
7
+ tag.reload
11
8
  tag.name.should be_nil
12
9
  I18n.locale = :en
13
10
  tag.name.should == 'hello'
14
11
  end
12
+
13
+ it "should create translation class automatically if it doesn't exists" do
14
+ Tag.translation_class.should_not be_nil
15
+ Tag.translation_class.table_name.should == 'tag_translations'
16
+ end
15
17
  end
data/spec/data/models.rb CHANGED
@@ -1,9 +1,13 @@
1
+ class ArticleTranslation < ActiveRecord::Base
2
+ translation_for :article
3
+ end
4
+
1
5
  class Article < ActiveRecord::Base
2
6
  translates :name, :content, :class_name => 'ArticleTranslation'
3
7
  end
4
8
 
5
- class ArticleTranslation < ActiveRecord::Base
6
- translation_for :article
9
+ class PostTranslation < ActiveRecord::Base
10
+ translation_for :post
7
11
  end
8
12
 
9
13
  class Post < ActiveRecord::Base
@@ -11,10 +15,6 @@ class Post < ActiveRecord::Base
11
15
  validate_translations :en, :ru
12
16
  end
13
17
 
14
- class PostTranslation < ActiveRecord::Base
15
- translation_for :post
16
- end
17
-
18
18
  class Tag < ActiveRecord::Base
19
19
  translates :name
20
20
  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: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pavel Forkert
@@ -140,13 +140,13 @@ files:
140
140
  - lib/simple_model_translations/validations.rb
141
141
  - simple_model_translations.gemspec
142
142
  - spec/attributes_spec.rb
143
+ - spec/auto_generated_translation_classes_spec.rb
143
144
  - spec/class_methods_spec.rb
144
145
  - spec/data/models.rb
145
146
  - spec/data/schema.rb
146
147
  - spec/simple_model_translations_spec.rb
147
148
  - spec/spec_helper.rb
148
149
  - spec/validations_spec.rb
149
- - spec/auto_generated_translation_classes_spec.rb
150
150
  has_rdoc: true
151
151
  homepage: http://github.com/fxposter/simple_model_translations
152
152
  licenses: []