translatable_records 1.1.2 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +73 -0
- data/lib/translatable_records/active_record/base.rb +0 -1
- data/lib/translatable_records/version.rb +1 -1
- data/test/dummy/config/environments/production.rb +5 -1
- data/test/dummy/config/environments/test.rb +9 -1
- data/test/dummy/log/test.log +1481 -0
- data/test/generators_test.rb +3 -4
- data/test/records_test.rb +4 -4
- metadata +8 -8
- data/README.rdoc +0 -55
data/test/generators_test.rb
CHANGED
@@ -3,15 +3,14 @@ require 'rails/generators'
|
|
3
3
|
require 'generators/translation_generator'
|
4
4
|
|
5
5
|
class GeneratorsTest < Rails::Generators::TestCase
|
6
|
+
tests TranslationGenerator
|
7
|
+
destination File.expand_path('../tmp', File.dirname(__FILE__))
|
6
8
|
|
7
9
|
teardown do
|
8
10
|
FileUtils.rm_rf self.destination_root
|
9
11
|
end
|
10
12
|
|
11
|
-
|
12
|
-
destination File.expand_path('../tmp', File.dirname(__FILE__))
|
13
|
-
|
14
|
-
test "generate files" do
|
13
|
+
test 'files generation' do
|
15
14
|
run_generator %w(model)
|
16
15
|
assert_file 'app/models/model_translation.rb'
|
17
16
|
assert_migration 'db/migrate/create_model_translations.rb'
|
data/test/records_test.rb
CHANGED
@@ -2,22 +2,22 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class RecordsTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
-
test
|
5
|
+
test 'associated translation creation' do
|
6
6
|
assert_equal 'name', record.name
|
7
7
|
end
|
8
8
|
|
9
|
-
test
|
9
|
+
test 'associated translation edition' do
|
10
10
|
record.name = 'new name'
|
11
11
|
record.save!
|
12
12
|
assert_equal 'new name', record.name
|
13
13
|
end
|
14
14
|
|
15
|
-
test
|
15
|
+
test 'associated translation deletion' do
|
16
16
|
record.destroy
|
17
17
|
assert_nil ModelTranslation.find_by_model_id(record.id)
|
18
18
|
end
|
19
19
|
|
20
|
-
test
|
20
|
+
test 'locale change' do
|
21
21
|
record.with_locale :es
|
22
22
|
assert_nil record.name
|
23
23
|
record.name = 'new name'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translatable_records
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Museways
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,8 +16,8 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "
|
19
|
+
version: 4.0.0
|
20
|
+
- - "<="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 4.2.0
|
23
23
|
type: :runtime
|
@@ -26,8 +26,8 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "
|
29
|
+
version: 4.0.0
|
30
|
+
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 4.2.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
@@ -52,7 +52,7 @@ extensions: []
|
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
54
|
- MIT-LICENSE
|
55
|
-
- README.
|
55
|
+
- README.md
|
56
56
|
- Rakefile
|
57
57
|
- lib/generators/templates/migration.rb
|
58
58
|
- lib/generators/templates/model.rb
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.4.5
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Translatable records for rails.
|
data/README.rdoc
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
{<img src="https://badge.fury.io/rb/translatable_records.png" alt="Gem Version" />}[http://badge.fury.io/rb/translatable_records] {<img src="https://codeclimate.com/github/museways/translatable_records.png" />}[https://codeclimate.com/github/museways/translatable_records] {<img src="https://secure.travis-ci.org/museways/translatable_records.png?branch=master" alt="Build Status" />}[https://travis-ci.org/museways/translatable_records]
|
2
|
-
|
3
|
-
= Translatable Records
|
4
|
-
|
5
|
-
Minimalistic toolkit to work with translatable records in rails.
|
6
|
-
|
7
|
-
= Install
|
8
|
-
|
9
|
-
Put this line in your Gemfile:
|
10
|
-
gem 'translatable_records'
|
11
|
-
|
12
|
-
Then bundle:
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
= Configuration
|
16
|
-
|
17
|
-
Define wich attributes will be translatable with the attr_translatable in your models:
|
18
|
-
attr_translatable :attr
|
19
|
-
|
20
|
-
Generate the translation model and migration for them:
|
21
|
-
rails g translation model
|
22
|
-
|
23
|
-
Complete the migrations adding the columns for each field in the translatations tables:
|
24
|
-
add_column :model_translations, :attr, :string
|
25
|
-
|
26
|
-
Remove the original column from models table:
|
27
|
-
remove_column :model, :attr
|
28
|
-
|
29
|
-
Update your db:
|
30
|
-
rake db:migrate
|
31
|
-
|
32
|
-
NOTE: If you are using rails 3 you should add attr_accessible :attr to pass the atrr to create, update, etc.
|
33
|
-
|
34
|
-
= Usage
|
35
|
-
|
36
|
-
If you want to change the locale to something different than I18n.locale:
|
37
|
-
record.with_locale :es
|
38
|
-
|
39
|
-
If you want to build a translation for each available locale:
|
40
|
-
record.build_translations
|
41
|
-
|
42
|
-
If you want to save multiple translations:
|
43
|
-
<%= f.fields_for :translations do |ff| %>
|
44
|
-
<%= ff.hidden_field :locale %>
|
45
|
-
<%= ff.label :attr %>
|
46
|
-
<%= ff.text_field :attr %>
|
47
|
-
<% end %>
|
48
|
-
|
49
|
-
= Credits
|
50
|
-
|
51
|
-
This gem is maintained and funded by museways[http://museways.com].
|
52
|
-
|
53
|
-
= License
|
54
|
-
|
55
|
-
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|