efficient_translations 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/efficient_translations/translates_method.rb +1 -1
- data/lib/efficient_translations/translation_factory.rb +2 -2
- data/lib/efficient_translations/version.rb +1 -1
- data/spec/lib/efficient_translations/translates_method_spec.rb +4 -3
- data/spec/lib/efficient_translations/translation_factory_spec.rb +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -114,7 +114,7 @@ module EfficientTranslations
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def default_locale_required
|
117
|
-
|
117
|
+
if efficient_translations_attributes[I18n.default_locale.to_sym].blank? && translations.detect { |t| t.locale.to_sym == I18n.default_locale.to_sym }.nil?
|
118
118
|
# people may expect this message to be localized too ;-)
|
119
119
|
errors.add :translations, "for #{I18n.default_locale} is missing"
|
120
120
|
end
|
@@ -9,9 +9,9 @@ module EfficientTranslations
|
|
9
9
|
table_name = "#{base_model.table_name.singularize}_translations"
|
10
10
|
cattr_accessor :translatable_model, :translatable_relation_field
|
11
11
|
self.translatable_model = base_model
|
12
|
-
self.translatable_relation_field = base_model.
|
12
|
+
self.translatable_relation_field = base_model.model_name.underscore.gsub '/', '_'
|
13
13
|
|
14
|
-
belongs_to translatable_relation_field
|
14
|
+
belongs_to translatable_relation_field, :class_name => self.translatable_model.name
|
15
15
|
before_save :stringify_locale!
|
16
16
|
|
17
17
|
named_scope :for_locale, lambda { |locale|
|
@@ -4,7 +4,7 @@ require 'active_record'
|
|
4
4
|
describe EfficientTranslations do
|
5
5
|
def my_model_class
|
6
6
|
Kernel.silence_warnings do
|
7
|
-
|
7
|
+
Object.const_set :MyModel, Class.new(ActiveRecord::Base)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -47,8 +47,9 @@ describe EfficientTranslations do
|
|
47
47
|
model = my_model_class
|
48
48
|
model.translates :name
|
49
49
|
model.validates_presence_of_default_locale
|
50
|
-
|
51
|
-
|
50
|
+
inst = model.new
|
51
|
+
lambda { inst.save! }.should raise_error ActiveRecord::RecordInvalid
|
52
|
+
inst.set_name_translation I18n.default_locale, 'pippo'
|
52
53
|
lambda { inst.save! }.should_not raise_error
|
53
54
|
end
|
54
55
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe EfficientTranslations::TranslationFactory do
|
4
4
|
before :each do
|
5
5
|
Kernel.silence_warnings do
|
6
|
-
@model_class =
|
6
|
+
@model_class = Object.const_set :MyModel, Class.new(ActiveRecord::Base)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: efficient_translations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nicola Racco
|