simonmenke-globalize2 0.0.1 → 0.0.4
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.
@@ -30,7 +30,7 @@ module Globalize
|
|
30
30
|
:class_name => globalize_proxy.name,
|
31
31
|
:extend => Extensions,
|
32
32
|
:dependent => :delete_all,
|
33
|
-
:foreign_key =>
|
33
|
+
:foreign_key => self.name.gsub(/.+::/, '').foreign_key
|
34
34
|
)
|
35
35
|
|
36
36
|
after_save :update_globalize_record
|
@@ -90,9 +90,9 @@ module Globalize
|
|
90
90
|
raise BadMigrationFieldType, "Bad field type for #{name}, should be :string or :text"
|
91
91
|
end
|
92
92
|
end
|
93
|
-
translation_table_name = self.name.underscore + '_translations'
|
93
|
+
translation_table_name = self.name.underscore.gsub('/', '_') + '_translations'
|
94
94
|
self.connection.create_table(translation_table_name) do |t|
|
95
|
-
t.
|
95
|
+
t.integer self.name.gsub(/.+::/, '').foreign_key
|
96
96
|
t.string :locale
|
97
97
|
fields.each do |name, type|
|
98
98
|
t.column name, type
|
@@ -102,14 +102,14 @@ module Globalize
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def drop_translation_table!
|
105
|
-
translation_table_name = self.name.underscore + '_translations'
|
105
|
+
translation_table_name = self.name.underscore.gsub('/', '_') + '_translations'
|
106
106
|
self.connection.drop_table translation_table_name
|
107
107
|
end
|
108
108
|
|
109
109
|
private
|
110
110
|
|
111
111
|
def i18n_attr(attribute_name)
|
112
|
-
self.base_class.name.underscore + "_translations.#{attribute_name}"
|
112
|
+
self.base_class.name.underscore.gsub('/', '_') + "_translations.#{attribute_name}"
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
@@ -6,10 +6,12 @@ require 'globalize/model/active_record/translated'
|
|
6
6
|
module Globalize
|
7
7
|
module Model
|
8
8
|
module ActiveRecord
|
9
|
-
class << self
|
9
|
+
class << self
|
10
10
|
def create_proxy_class(klass)
|
11
|
-
|
12
|
-
|
11
|
+
short_name = klass.name.gsub(/.+::/, '')
|
12
|
+
klass.parent.const_set "#{short_name}Translation", Class.new(::ActiveRecord::Base){
|
13
|
+
set_table_name "#{klass.name}Translation".pluralize.underscore.gsub('/', '_')
|
14
|
+
belongs_to "#{short_name.underscore}".intern, :class_name => klass.name, :foreign_key => "#{short_name.underscore}_id"
|
13
15
|
|
14
16
|
def locale
|
15
17
|
read_attribute(:locale).to_sym
|
data/lib/globalize.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simonmenke-globalize2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Harvey
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/globalize/model/active_record/translated.rb
|
35
35
|
- lib/globalize/model/active_record.rb
|
36
36
|
- lib/globalize/translation.rb
|
37
|
+
- lib/globalize.rb
|
37
38
|
- lib/rails_edge_load_path_patch.rb
|
38
39
|
- rails/init.rb
|
39
40
|
- test/backends/chained_test.rb
|