activerecord-hackery / ransack

Object-based searching.
https://activerecord-hackery.github.io/ransack/
MIT License
5.66k stars 799 forks source link

Polymorphic Search not working on nested association #1457

Closed devsheva closed 11 months ago

devsheva commented 11 months ago

Example:


# Order
class Order < ApplicationRecord
  has_many :order_items, dependent: :destroy

# OrderItem
class OrderItem < ApplicationRecord
  belongs_to :order
  belongs_to :itemable, polymorphic: true, optional: true

# Ransack query
order_items_itemable_of_DomainContract_type_dns_eq: chunk

Given error:

ActiveRecord::EagerLoadPolymorphicError: Cannot eagerly load the polymorphic association :itemable

Anyone has experienced the same problem, or knows a workaround ?

devsheva commented 11 months ago

EDIT: My bad, i'll close this issue, it was a bug in my test