simple_model_translations 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,8 +17,9 @@ module SimpleModelTranslations
|
|
17
17
|
# class Post < ActiveRecord::Base
|
18
18
|
# translates :title, :description, :attributes => true
|
19
19
|
# end
|
20
|
-
def translates(*attributes)
|
20
|
+
def translates(*attributes, &block)
|
21
21
|
configure_translations(attributes.extract_options!)
|
22
|
+
translation_class.class_eval(&block) if block_given?
|
22
23
|
|
23
24
|
attributes.each do |attribute|
|
24
25
|
# attribute setter
|
data/spec/data/models.rb
CHANGED
data/spec/data/schema.rb
CHANGED
@@ -45,5 +45,12 @@ ActiveRecord::Schema.define do
|
|
45
45
|
t.references :some_models
|
46
46
|
t.string :name
|
47
47
|
end
|
48
|
+
|
49
|
+
create_table :books, :force => true
|
50
|
+
create_table :book_translations, :force => true do |t|
|
51
|
+
t.string :locale
|
52
|
+
t.references :book
|
53
|
+
t.string :name
|
54
|
+
end
|
48
55
|
end
|
49
56
|
|
data/spec/validations_spec.rb
CHANGED
@@ -12,3 +12,11 @@ describe Post do
|
|
12
12
|
post.should_not be_valid
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
describe Book do
|
17
|
+
it 'should validate presence of name' do
|
18
|
+
book = Book.new(:locale => :ru, :name => '')
|
19
|
+
book.should_not be_valid
|
20
|
+
book.errors['translations.name'].should_not be_empty
|
21
|
+
end
|
22
|
+
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pavel Forkert
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-15 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|