activerecord 4.1.1 → 4.1.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG.md +312 -0
- data/lib/active_record/association_relation.rb +4 -0
- data/lib/active_record/associations.rb +24 -3
- data/lib/active_record/associations/association.rb +1 -1
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +10 -4
- data/lib/active_record/associations/builder/has_many.rb +1 -1
- data/lib/active_record/associations/collection_association.rb +5 -5
- data/lib/active_record/associations/collection_proxy.rb +4 -0
- data/lib/active_record/associations/has_many_association.rb +6 -5
- data/lib/active_record/associations/has_many_through_association.rb +6 -2
- data/lib/active_record/associations/join_dependency.rb +1 -1
- data/lib/active_record/associations/join_dependency/join_association.rb +1 -1
- data/lib/active_record/associations/preloader.rb +14 -35
- data/lib/active_record/associations/preloader/association.rb +26 -5
- data/lib/active_record/associations/singular_association.rb +3 -3
- data/lib/active_record/associations/through_association.rb +4 -2
- data/lib/active_record/attribute_methods.rb +2 -0
- data/lib/active_record/attribute_methods/dirty.rb +2 -2
- data/lib/active_record/attribute_methods/serialization.rb +24 -5
- data/lib/active_record/attribute_methods/write.rb +22 -14
- data/lib/active_record/autosave_association.rb +40 -35
- data/lib/active_record/base.rb +2 -2
- data/lib/active_record/callbacks.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +10 -13
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +1 -0
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +7 -1
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +1 -1
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +8 -6
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +1 -4
- data/lib/active_record/connection_adapters/postgresql/oid.rb +10 -5
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +9 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +11 -6
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +7 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +6 -3
- data/lib/active_record/connection_handling.rb +2 -2
- data/lib/active_record/core.rb +3 -0
- data/lib/active_record/counter_cache.rb +2 -3
- data/lib/active_record/fixtures.rb +1 -1
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/locking/optimistic.rb +1 -1
- data/lib/active_record/log_subscriber.rb +1 -1
- data/lib/active_record/migration.rb +1 -1
- data/lib/active_record/nested_attributes.rb +2 -2
- data/lib/active_record/null_relation.rb +19 -5
- data/lib/active_record/persistence.rb +8 -8
- data/lib/active_record/railties/databases.rake +3 -2
- data/lib/active_record/reflection.rb +45 -13
- data/lib/active_record/relation.rb +7 -6
- data/lib/active_record/relation/calculations.rb +10 -2
- data/lib/active_record/relation/delegation.rb +2 -2
- data/lib/active_record/relation/finder_methods.rb +1 -1
- data/lib/active_record/relation/merger.rb +10 -2
- data/lib/active_record/relation/predicate_builder.rb +2 -2
- data/lib/active_record/relation/query_methods.rb +2 -2
- data/lib/active_record/scoping/default.rb +3 -3
- data/lib/active_record/store.rb +14 -5
- data/lib/active_record/timestamp.rb +2 -2
- data/lib/active_record/transactions.rb +1 -1
- data/lib/active_record/validations/presence.rb +1 -1
- data/lib/active_record/validations/uniqueness.rb +2 -2
- metadata +27 -35
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2aca93fe15c355b8cd4de74c821591b11d0f2e9e
|
4
|
+
data.tar.gz: 4f0d15d06ec38cfc876be6fdab7a6e79cb47d4b9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 557f017b351b3e629907d188ba6aaa0d18e010314f84dcdf5eca5d1fafc93f6d1d58ff89ed181f196809c03899886f324765797d6bd365e581f4c93aa8853967
|
7
|
+
data.tar.gz: 167461b2b4db82feadabd726816d5442534a088700646a7305b3d83eeb5984d8b1be4fd9e2ba815aa01386498ba22ee7aca58d9a75b01dffc88f886ca226af3b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,314 @@
|
|
1
|
+
## Rails 4.1.2 (May 27, 2014) ##
|
2
|
+
|
3
|
+
* Fix redefine a has_and_belongs_to_many inside inherited class
|
4
|
+
Fixing regression case, where redefining the same has_an_belongs_to_many
|
5
|
+
definition into a subclass would raise.
|
6
|
+
|
7
|
+
Fixes #14983.
|
8
|
+
|
9
|
+
*arthurnn*
|
10
|
+
|
11
|
+
* Fix has_and_belongs_to_many public reflection.
|
12
|
+
When defining a has_and_belongs_to_many, internally we convert that to two has_many.
|
13
|
+
But as `reflections` is a public API, people expect to see the right macro.
|
14
|
+
|
15
|
+
Fixes #14682.
|
16
|
+
|
17
|
+
*arthurnn*
|
18
|
+
|
19
|
+
* Fixed serialization for records with an attribute named `format`.
|
20
|
+
|
21
|
+
Fixes #15188.
|
22
|
+
|
23
|
+
*Godfrey Chan*
|
24
|
+
|
25
|
+
* Fixed serialized fields returning serialized data after being updated with
|
26
|
+
`update_column`.
|
27
|
+
|
28
|
+
*Simon Hørup Eskildsen*
|
29
|
+
|
30
|
+
* When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
|
31
|
+
on a NullRelation should return a Hash.
|
32
|
+
|
33
|
+
*Kuldeep Aggarwal*
|
34
|
+
|
35
|
+
* Fixed polymorphic eager loading when using a String as foreign key.
|
36
|
+
|
37
|
+
Fixes #14734.
|
38
|
+
|
39
|
+
*Lauro Caetano*
|
40
|
+
|
41
|
+
* Fixed the inferred table name of a has_and_belongs_to_many auxiliar
|
42
|
+
table inside a schema.
|
43
|
+
|
44
|
+
Fixes #14824
|
45
|
+
|
46
|
+
*Eric Chahin*
|
47
|
+
|
48
|
+
* Fix bug that added `table_name_prefix` and `table_name_suffix` to
|
49
|
+
extension names in PostgreSQL when migrating.
|
50
|
+
|
51
|
+
*Joao Carlos*
|
52
|
+
|
53
|
+
* Floats with limit >= 25 that get turned into doubles in MySQL no longer have
|
54
|
+
their limit dropped from the schema.
|
55
|
+
|
56
|
+
Fixes #14135.
|
57
|
+
|
58
|
+
*Aaron Nelson*
|
59
|
+
|
60
|
+
* Fix how to calculate associated class name when using namespaced has_and_belongs_to_many
|
61
|
+
association.
|
62
|
+
|
63
|
+
Fixes #14709.
|
64
|
+
|
65
|
+
*Kassio Borges*
|
66
|
+
|
67
|
+
* `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
|
68
|
+
strings in column names as equal.
|
69
|
+
|
70
|
+
This fixes a rare case in which more bind values are passed than there are
|
71
|
+
placeholders for them in the generated SQL statement, which can make PostgreSQL
|
72
|
+
throw a `StatementInvalid` exception.
|
73
|
+
|
74
|
+
*Nat Budin*
|
75
|
+
|
76
|
+
* Fix `stored_attributes` to correctly merge the details of stored
|
77
|
+
attributes defined in parent classes.
|
78
|
+
|
79
|
+
Fixes #14672.
|
80
|
+
|
81
|
+
*Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
|
82
|
+
|
83
|
+
* `change_column_default` allows `[]` as argument to `change_column_default`.
|
84
|
+
|
85
|
+
Fixes #11586.
|
86
|
+
|
87
|
+
*Yves Senn*
|
88
|
+
|
89
|
+
* Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
|
90
|
+
NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
|
91
|
+
|
92
|
+
Example:
|
93
|
+
|
94
|
+
# Before
|
95
|
+
Point.create(value: 1.0/0)
|
96
|
+
Point.last.value # => 0.0
|
97
|
+
|
98
|
+
# After
|
99
|
+
Point.create(value: 1.0/0)
|
100
|
+
Point.last.value # => Infinity
|
101
|
+
|
102
|
+
*Innokenty Mikhailov*
|
103
|
+
|
104
|
+
* Allow the PostgreSQL adapter to handle bigserial primary key types again.
|
105
|
+
|
106
|
+
Fixes #10410.
|
107
|
+
|
108
|
+
*Patrick Robertson*
|
109
|
+
|
110
|
+
* Fixed has_and_belongs_to_many's CollectionAssociation size calculation.
|
111
|
+
|
112
|
+
has_and_belongs_to_many should fall back to using the normal CollectionAssociation's
|
113
|
+
size calculation if the collection is not cached or loaded.
|
114
|
+
|
115
|
+
Fixes #14913 and #14914.
|
116
|
+
|
117
|
+
*Fred Wu*
|
118
|
+
|
119
|
+
* Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
|
120
|
+
|
121
|
+
In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
|
122
|
+
In 4.0 series it is delegated to `Array#join`.
|
123
|
+
|
124
|
+
*Bogdan Gusiev*
|
125
|
+
|
126
|
+
* Log nil binary column values correctly.
|
127
|
+
|
128
|
+
When an object with a binary column is updated with a nil value
|
129
|
+
in that column, the SQL logger would throw an exception when trying
|
130
|
+
to log that nil value. This only occurs when updating a record
|
131
|
+
that already has a non-nil value in that column since an initial nil
|
132
|
+
value isn't included in the SQL anyway (at least, when dirty checking
|
133
|
+
is enabled.) The column's new value will now be logged as `<NULL binary data>`
|
134
|
+
to parallel the existing `<N bytes of binary data>` for non-nil values.
|
135
|
+
|
136
|
+
*James Coleman*
|
137
|
+
|
138
|
+
* Stringify all variables keys of MySQL connection configuration.
|
139
|
+
|
140
|
+
When `sql_mode` variable for MySQL adapters set in configuration as `String`
|
141
|
+
was ignored and overwritten by strict mode option.
|
142
|
+
|
143
|
+
Fixes #14895.
|
144
|
+
|
145
|
+
*Paul Nikitochkin*
|
146
|
+
|
147
|
+
* Ensure SQLite3 statements are closed on errors.
|
148
|
+
|
149
|
+
Fixes #13631.
|
150
|
+
|
151
|
+
*Timur Alperovich*
|
152
|
+
|
153
|
+
* Fix excluding lower bounds of PostgreSQL date and int ranges.
|
154
|
+
|
155
|
+
*River MacLeod*, *Yves Senn*
|
156
|
+
|
157
|
+
* When using a custom `join_table` name on a `habtm`, rails was not saving it
|
158
|
+
on Reflections. This causes a problem when rails loads fixtures, because it
|
159
|
+
uses the reflections to set database with fixtures.
|
160
|
+
|
161
|
+
Fixes #14845.
|
162
|
+
|
163
|
+
*Kassio Borges*
|
164
|
+
|
165
|
+
* `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
|
166
|
+
|
167
|
+
Fixes #14841.
|
168
|
+
|
169
|
+
*Lucas Mazza*
|
170
|
+
|
171
|
+
* Fix name collision with `Array#select!` with `Relation#select!`.
|
172
|
+
|
173
|
+
Fixes #14752.
|
174
|
+
|
175
|
+
*Earl St Sauver*
|
176
|
+
|
177
|
+
* Fixed unexpected behavior for `has_many :through` associations going through a scoped `has_many`.
|
178
|
+
|
179
|
+
If a `has_many` association is adjusted using a scope, and another `has_many :through`
|
180
|
+
uses this association, then the scope adjustment is unexpectedly neglected.
|
181
|
+
|
182
|
+
Fixes #14537.
|
183
|
+
|
184
|
+
*Jan Habermann*
|
185
|
+
|
186
|
+
* When a destroyed record is duped, the dup is not `destroyed?`.
|
187
|
+
|
188
|
+
*Kuldeep Aggarwal*
|
189
|
+
|
190
|
+
* Fixed has_many association to make it support irregular inflections.
|
191
|
+
|
192
|
+
Fixes #8928.
|
193
|
+
|
194
|
+
*arthurnn*, *Javier Goizueta*
|
195
|
+
|
196
|
+
* Calling `delete_all` on an unloaded `CollectionProxy` no longer
|
197
|
+
generates a SQL statement containing each id of the collection:
|
198
|
+
|
199
|
+
Before:
|
200
|
+
|
201
|
+
DELETE FROM `model` WHERE `model`.`parent_id` = 1
|
202
|
+
AND `model`.`id` IN (1, 2, 3...)
|
203
|
+
|
204
|
+
After:
|
205
|
+
|
206
|
+
DELETE FROM `model` WHERE `model`.`parent_id` = 1
|
207
|
+
|
208
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
209
|
+
|
210
|
+
* Fixed a problem where count used with a grouping was not returning a Hash.
|
211
|
+
|
212
|
+
Fixes #14721.
|
213
|
+
|
214
|
+
*Eric Chahin*
|
215
|
+
|
216
|
+
* Do not quote uuid default value on `change_column`.
|
217
|
+
|
218
|
+
Fixes #14604.
|
219
|
+
|
220
|
+
*Eric Chahin*
|
221
|
+
|
222
|
+
* The comparison between `Relation` and `CollectionProxy` should be consistent.
|
223
|
+
|
224
|
+
Example:
|
225
|
+
|
226
|
+
author.posts == Post.where(author_id: author.id)
|
227
|
+
# => true
|
228
|
+
Post.where(author_id: author.id) == author.posts
|
229
|
+
# => true
|
230
|
+
|
231
|
+
Fixes #13506.
|
232
|
+
|
233
|
+
*Lauro Caetano*
|
234
|
+
|
235
|
+
* PostgreSQL adapter only warns once for every missing OID per connection.
|
236
|
+
|
237
|
+
Fixes #14275.
|
238
|
+
|
239
|
+
*Matthew Draper*, *Yves Senn*
|
240
|
+
|
241
|
+
* Fixed error for aggregate methods (`empty?`, `any?`, `count`) with `select`
|
242
|
+
which created invalid SQL.
|
243
|
+
|
244
|
+
Fixes #13648.
|
245
|
+
|
246
|
+
*Simon Woker*
|
247
|
+
|
248
|
+
* Fix insertion of records via `has_many :through` association with scope.
|
249
|
+
|
250
|
+
Fixes #3548.
|
251
|
+
|
252
|
+
*Ivan Antropov*
|
253
|
+
|
254
|
+
* Make possible to have an association called `records`.
|
255
|
+
|
256
|
+
Fixes #11645.
|
257
|
+
|
258
|
+
*prathamesh-sonpatki*
|
259
|
+
|
260
|
+
* `to_sql` on an association now matches the query that is actually executed, where it
|
261
|
+
could previously have incorrectly accrued additional conditions (e.g. as a result of
|
262
|
+
a previous query). CollectionProxy now always defers to the association scope's
|
263
|
+
`arel` method so the (incorrect) inherited one should be entirely concealed.
|
264
|
+
|
265
|
+
Fixes #14003.
|
266
|
+
|
267
|
+
*Jefferson Lai*
|
268
|
+
|
269
|
+
* Fixed error when using `with_options` with lambda.
|
270
|
+
|
271
|
+
Fixes #9805.
|
272
|
+
|
273
|
+
*Lauro Caetano*
|
274
|
+
|
275
|
+
* Fixed error when specifying a non-empty default value on a PostgreSQL array column.
|
276
|
+
|
277
|
+
Fixes #10613.
|
278
|
+
|
279
|
+
*Luke Steensen*
|
280
|
+
|
281
|
+
* Make possible to change `record_timestamps` inside Callbacks.
|
282
|
+
|
283
|
+
*Tieg Zaharia*
|
284
|
+
|
285
|
+
* Fixed error where .persisted? throws SystemStackError for an unsaved model with a
|
286
|
+
custom primary key that didn't save due to validation error.
|
287
|
+
|
288
|
+
Fixes #14393.
|
289
|
+
|
290
|
+
*Chris Finne*
|
291
|
+
|
292
|
+
* `rake db:structure:dump` only dumps schema information if the schema
|
293
|
+
migration table exists.
|
294
|
+
|
295
|
+
Fixes #14217.
|
296
|
+
|
297
|
+
*Yves Senn*
|
298
|
+
|
299
|
+
* Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
|
300
|
+
|
301
|
+
Fixes #14361.
|
302
|
+
|
303
|
+
*arthurnn*
|
304
|
+
|
305
|
+
* Only save `has_one` associations if record has changes. Previously after save
|
306
|
+
related callbacks, such as `#after_commit`, were triggered when the
|
307
|
+
`has_one` object did not get saved to the db.
|
308
|
+
|
309
|
+
*Alan Kennedy*
|
310
|
+
|
311
|
+
|
1
312
|
## Rails 4.1.1 (May 6, 2014) ##
|
2
313
|
|
3
314
|
* No changes.
|
@@ -12,6 +323,7 @@
|
|
12
323
|
|
13
324
|
*Evan Whalen*
|
14
325
|
|
326
|
+
|
15
327
|
* Block a few default Class methods as scope name.
|
16
328
|
|
17
329
|
For instance, this will raise:
|
@@ -4,6 +4,12 @@ require 'active_support/core_ext/module/remove_method'
|
|
4
4
|
require 'active_record/errors'
|
5
5
|
|
6
6
|
module ActiveRecord
|
7
|
+
class AssociationNotFoundError < ConfigurationError #:nodoc:
|
8
|
+
def initialize(record, association_name)
|
9
|
+
super("Association named '#{association_name}' was not found on #{record.class.name}; perhaps you misspelled it?")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
7
13
|
class InverseOfAssociationNotFoundError < ActiveRecordError #:nodoc:
|
8
14
|
def initialize(reflection, associated_class = nil)
|
9
15
|
super("Could not find the inverse association for #{reflection.name} (#{reflection.options[:inverse_of].inspect} in #{associated_class.nil? ? reflection.class_name : associated_class.name})")
|
@@ -44,7 +50,7 @@ module ActiveRecord
|
|
44
50
|
def initialize(reflection)
|
45
51
|
through_reflection = reflection.through_reflection
|
46
52
|
source_reflection_names = reflection.source_reflection_names
|
47
|
-
source_associations = reflection.through_reflection.klass.
|
53
|
+
source_associations = reflection.through_reflection.klass._reflections.keys
|
48
54
|
super("Could not find the source association(s) #{source_reflection_names.collect{ |a| a.inspect }.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)}?")
|
49
55
|
end
|
50
56
|
end
|
@@ -145,7 +151,7 @@ module ActiveRecord
|
|
145
151
|
association = association_instance_get(name)
|
146
152
|
|
147
153
|
if association.nil?
|
148
|
-
reflection
|
154
|
+
raise AssociationNotFoundError.new(self, name) unless reflection = self.class._reflect_on_association(name)
|
149
155
|
association = reflection.association_class.new(self, reflection)
|
150
156
|
association_instance_set(name, association)
|
151
157
|
end
|
@@ -767,6 +773,12 @@ module ActiveRecord
|
|
767
773
|
# like this can have unintended consequences.
|
768
774
|
# In the above example posts with no approved comments are not returned at all, because
|
769
775
|
# the conditions apply to the SQL statement as a whole and not just to the association.
|
776
|
+
#
|
777
|
+
# If you want to load all posts (including posts with no approved comments) then write
|
778
|
+
# your own LEFT OUTER JOIN query using ON
|
779
|
+
#
|
780
|
+
# Post.joins('LEFT OUTER JOIN comments ON comments.post_id = posts.id AND comments.approved = true')
|
781
|
+
#
|
770
782
|
# You must disambiguate column references for this fallback to happen, for example
|
771
783
|
# <tt>order: "author.name DESC"</tt> will work but <tt>order: "name DESC"</tt> will not.
|
772
784
|
#
|
@@ -1561,14 +1573,22 @@ module ActiveRecord
|
|
1561
1573
|
scope = nil
|
1562
1574
|
end
|
1563
1575
|
|
1576
|
+
habtm_reflection = ActiveRecord::Reflection::AssociationReflection.new(:has_and_belongs_to_many, name, scope, options, self)
|
1577
|
+
|
1564
1578
|
builder = Builder::HasAndBelongsToMany.new name, self, options
|
1565
1579
|
|
1566
1580
|
join_model = builder.through_model
|
1567
1581
|
|
1582
|
+
# FIXME: we should move this to the internal constants. Also people
|
1583
|
+
# should never directly access this constant so I'm not happy about
|
1584
|
+
# setting it.
|
1585
|
+
const_set join_model.name, join_model
|
1586
|
+
|
1568
1587
|
middle_reflection = builder.middle_reflection join_model
|
1569
1588
|
|
1570
1589
|
Builder::HasMany.define_callbacks self, middle_reflection
|
1571
1590
|
Reflection.add_reflection self, middle_reflection.name, middle_reflection
|
1591
|
+
middle_reflection.parent_reflection = [name, habtm_reflection]
|
1572
1592
|
|
1573
1593
|
include Module.new {
|
1574
1594
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
@@ -1584,11 +1604,12 @@ module ActiveRecord
|
|
1584
1604
|
hm_options[:through] = middle_reflection.name
|
1585
1605
|
hm_options[:source] = join_model.right_reflection.name
|
1586
1606
|
|
1587
|
-
[:before_add, :after_add, :before_remove, :after_remove, :autosave, :validate].each do |k|
|
1607
|
+
[:before_add, :after_add, :before_remove, :after_remove, :autosave, :validate, :join_table].each do |k|
|
1588
1608
|
hm_options[k] = options[k] if options.key? k
|
1589
1609
|
end
|
1590
1610
|
|
1591
1611
|
has_many name, scope, hm_options, &extension
|
1612
|
+
self._reflections[name].parent_reflection = [name, habtm_reflection]
|
1592
1613
|
end
|
1593
1614
|
end
|
1594
1615
|
end
|
@@ -160,7 +160,7 @@ module ActiveRecord
|
|
160
160
|
def marshal_load(data)
|
161
161
|
reflection_name, ivars = data
|
162
162
|
ivars.each { |name, val| instance_variable_set(name, val) }
|
163
|
-
@reflection = @owner.class.
|
163
|
+
@reflection = @owner.class._reflect_on_association(reflection_name)
|
164
164
|
end
|
165
165
|
|
166
166
|
def initialize_attributes(record) #:nodoc:
|
@@ -11,7 +11,7 @@ module ActiveRecord::Associations::Builder
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def join_table
|
14
|
-
@join_table ||= [@lhs_class.table_name, klass.table_name].sort.join("\0").gsub(/^(.*_)(.+)\0\1(.+)/, '\1\2_\3').gsub("\0", "_")
|
14
|
+
@join_table ||= [@lhs_class.table_name, klass.table_name].sort.join("\0").gsub(/^(.*[._])(.+)\0\1(.+)/, '\1\2_\3').gsub("\0", "_")
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -23,7 +23,13 @@ module ActiveRecord::Associations::Builder
|
|
23
23
|
KnownTable.new options[:join_table].to_s
|
24
24
|
else
|
25
25
|
class_name = options.fetch(:class_name) {
|
26
|
-
name.to_s.camelize.singularize
|
26
|
+
model_name = name.to_s.camelize.singularize
|
27
|
+
|
28
|
+
if lhs_class.parent_name
|
29
|
+
model_name.prepend("#{lhs_class.parent_name}::")
|
30
|
+
end
|
31
|
+
|
32
|
+
model_name
|
27
33
|
}
|
28
34
|
KnownClass.new lhs_class, class_name
|
29
35
|
end
|
@@ -60,13 +66,13 @@ module ActiveRecord::Associations::Builder
|
|
60
66
|
|
61
67
|
def self.add_left_association(name, options)
|
62
68
|
belongs_to name, options
|
63
|
-
self.left_reflection =
|
69
|
+
self.left_reflection = _reflect_on_association(name)
|
64
70
|
end
|
65
71
|
|
66
72
|
def self.add_right_association(name, options)
|
67
73
|
rhs_name = name.to_s.singularize.to_sym
|
68
74
|
belongs_to rhs_name, options
|
69
|
-
self.right_reflection =
|
75
|
+
self.right_reflection = _reflect_on_association(rhs_name)
|
70
76
|
end
|
71
77
|
|
72
78
|
}
|