rare_map 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rare_map/model_builder.rb +2 -2
- data/lib/rare_map/model_generator.rb +3 -2
- data/lib/rare_map/version.rb +1 -1
- metadata +2 -2
@@ -53,10 +53,10 @@ module RareMap
|
|
53
53
|
rel_from.table != rel_to.table
|
54
54
|
model_from = models.find { |m| m.table.name == rel_from.table &&
|
55
55
|
m.group == model.group &&
|
56
|
-
m.db_name
|
56
|
+
m.db_name == model.db_name }
|
57
57
|
model_to = models.find { |m| m.table.name == rel_to.table &&
|
58
58
|
m.group == model.group &&
|
59
|
-
m.db_name
|
59
|
+
m.db_name == model.db_name }
|
60
60
|
model_from.relations << Relation.new(:has_many_through, rel_to.foreign_key, model_to.table.name, model.table.name)
|
61
61
|
model_to.relations << Relation.new(:has_many_through, rel_from.foreign_key, model_from.table.name, model.table.name)
|
62
62
|
end
|
@@ -69,14 +69,15 @@ module RareMap
|
|
69
69
|
def generate_connection_models(models, path)
|
70
70
|
group_db2conn = {}
|
71
71
|
|
72
|
-
group2connection = Hash[models.map { |model| [[model.group, model.db_name], model.connection] }]
|
73
|
-
group2connection.each do |(group, db_name), connection|
|
72
|
+
group2connection = Hash[models.map { |model| [[model.group, model.db_name], [model.connection, model.table.name]] }]
|
73
|
+
group2connection.each do |(group, db_name), (connection, table_name)|
|
74
74
|
model = "#{group}_#{db_name}".camelize + 'Base'
|
75
75
|
|
76
76
|
output = ''
|
77
77
|
output <<
|
78
78
|
"class #{model} < ActiveRecord::Base\n" <<
|
79
79
|
" establish_connection #{connection.map { |k, v| ":#{k} => #{v.inspect}" }.join(', ')}\n" <<
|
80
|
+
" self.table_name = '#{table_name}'\n" <<
|
80
81
|
'end'
|
81
82
|
|
82
83
|
|
data/lib/rare_map/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rare_map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
segments:
|
144
144
|
- 0
|
145
|
-
hash: -
|
145
|
+
hash: -2233758671906333184
|
146
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
147
|
none: false
|
148
148
|
requirements:
|