mongoid_translate 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -14
- data/lib/mongoid/translate/resources.rb +27 -0
- data/lib/mongoid/translate/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfc910bb3f10d4ff535d9240b6384c0a5b065457
|
4
|
+
data.tar.gz: a86c3607a6fb1dfd41c7761e6cc6f5972206f2c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fe49f8645e01f7252893d5c97af9fa5a5ddcc9f375cc258b44fa04bc16c6104bf231f199d020e2cca169ed616e278cf2026bdf984f2d571093e0c9dc98d8709
|
7
|
+
data.tar.gz: 416074aff31c2301326f003329219e8d6aae28a322fb1a5be1253dc352a60053c27375260110b87a5618a22d0fc1c98c39f73642faa4d91630ac28c1dce2b015
|
data/README.md
CHANGED
@@ -112,20 +112,8 @@ Controller with InheritedResources
|
|
112
112
|
----------------------------------
|
113
113
|
|
114
114
|
``` ruby
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
def build_translations
|
119
|
-
(I18n.available_locales - resource.languages).each do |language|
|
120
|
-
resource.translations.build(language: language)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def build_translations_for_new
|
125
|
-
(I18n.available_locales - build_resource.languages).each do |language|
|
126
|
-
build_resource.translations.build(language: language)
|
127
|
-
end
|
128
|
-
end
|
115
|
+
require 'mongoid/translate/resources'
|
116
|
+
include Mongoid::Translate::Resources
|
129
117
|
```
|
130
118
|
|
131
119
|
Use slug on views with to_slug
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Mongoid
|
3
|
+
module Translate
|
4
|
+
module Resources
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
before_filter :build_translations, only: :edit
|
9
|
+
before_filter :build_translations_for_new, only: :new
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def build_translations
|
15
|
+
(I18n.available_locales - resource.languages).each do |language|
|
16
|
+
resource.translations.build(language: language)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_translations_for_new
|
21
|
+
(I18n.available_locales - build_resource.languages).each do |language|
|
22
|
+
build_resource.translations.build(language: language)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chatgris
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- MIT-LICENSE
|
63
63
|
- README.md
|
64
64
|
- lib/mongoid/translate.rb
|
65
|
+
- lib/mongoid/translate/resources.rb
|
65
66
|
- lib/mongoid/translate/slug.rb
|
66
67
|
- lib/mongoid/translate/version.rb
|
67
68
|
- lib/mongoid/translation.rb
|