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: 3a3ce02ada5c7878e2c6fab4642ba84c4ba7dbb7fb5986c7f8bc135ea8e3258c
4
- data.tar.gz: 375b538d786b4730626c5b7fb64a522ec04c789b750b25b2d4235f4617398e46
3
+ metadata.gz: 889c24801967683844b62d1e659862a39e47bfc99cf184ff77b9ecb9f0dbc16a
4
+ data.tar.gz: a39a146b713bc41482f35df016f3309c8afedef75531c5066479fe8d3ca6100c
5
5
  SHA512:
6
- metadata.gz: 65954757632e43d089f173c0e09e421c8c6528d4aa7da4fe70c7b2f24ce0f4ee90646ec8908a778e356846643cfe9d8b924dc7af2fb800a1b4040b8876a05889
7
- data.tar.gz: a1c6e51cba33a5489746a1d0954d547f4065fc75c69a87adaae35faca338c51ba91b36788c34729af74394b5d29ceeb9532b1d6acd7b8ffae06bf1ff29374f2b
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
- ((input.klass rescue nil).presence || _klass_by_name(input.class_name)) unless input.options[:polymorphic]
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.8.34'.freeze
2
+ VERSION = '1.8.35'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.34
4
+ version: 1.8.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect