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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b4a98762352bc9a1baa610fa3f0eaf811d32850
4
- data.tar.gz: 02e54081981f91e67bc8b0a0245410fc693906fa
3
+ metadata.gz: bfc910bb3f10d4ff535d9240b6384c0a5b065457
4
+ data.tar.gz: a86c3607a6fb1dfd41c7761e6cc6f5972206f2c0
5
5
  SHA512:
6
- metadata.gz: 623995e94c2d6f13db487992105c9036f6b1901e35fee76b8b6356cb89ccbb0be51d407ad10f1e31f766b4c6c91727f1b7fc5d815a8e812b10297a6c4e762d7f
7
- data.tar.gz: 68d88af09506f7df7056667863b5c4f400165b2e0d81f71b01f2d1073a9f9bc9c9f242d7958a76a40a684c102ab47fc31469936f899372b8997bbaddee47885a
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
- before_filter :build_translations, only: :edit
116
- before_filter :build_translations_for_new, only: :new
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
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Mongoid
3
3
  module Translate
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
6
6
  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.1
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