effective_resources 1.8.34 → 1.8.35
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 889c24801967683844b62d1e659862a39e47bfc99cf184ff77b9ecb9f0dbc16a
|
4
|
+
data.tar.gz: a39a146b713bc41482f35df016f3309c8afedef75531c5066479fe8d3ca6100c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac2de13588b807efd3fb9c048c0e180701d9b0dff54bf4ff1c44a86eb211b4ab9fc17da5fbea84725ce4c6cdc17fc9d242e749d257dd778209a7127655cc22bc
|
7
|
+
data.tar.gz: a7dd80308162e111383edb92c5964e32c7397116b574df8c20460e9571a705985f3b1d8ef6be28b9d743c08a89500fd34f2a830fa37751452db058fc34918c88
|
@@ -55,10 +55,12 @@ module Effective
|
|
55
55
|
input
|
56
56
|
when ActiveRecord::Relation
|
57
57
|
input.klass
|
58
|
-
when (ActiveRecord::Reflection::BelongsToReflection rescue :nil)
|
59
|
-
_klass_by_name(input.class_name)
|
60
58
|
when (ActiveRecord::Reflection::AbstractReflection rescue :nil)
|
61
|
-
|
59
|
+
if input.options[:polymorphic]
|
60
|
+
_klass_by_name(input.class_name)
|
61
|
+
else
|
62
|
+
(input.klass rescue nil) || _klass_by_name(input.class_name)
|
63
|
+
end
|
62
64
|
when ActiveRecord::Reflection::MacroReflection
|
63
65
|
((input.klass rescue nil).presence || _klass_by_name(input.class_name)) unless input.options[:polymorphic]
|
64
66
|
when ActionDispatch::Journey::Route
|
@@ -293,7 +293,10 @@ module Effective
|
|
293
293
|
# key: the id, or associated_id on my table
|
294
294
|
# keys: the ids themselves as per the target table
|
295
295
|
|
296
|
-
if association.macro == :belongs_to
|
296
|
+
if association.macro == :belongs_to && association.options[:polymorphic]
|
297
|
+
key = sql_column(association.foreign_key)
|
298
|
+
keys = relation.pluck((relation.klass.primary_key rescue nil))
|
299
|
+
elsif association.macro == :belongs_to
|
297
300
|
key = sql_column(association.foreign_key)
|
298
301
|
keys = relation.pluck(association.klass.primary_key)
|
299
302
|
elsif association.macro == :has_and_belongs_to_many
|