Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

702
Vistas
Multiple polymorphic association search using Ransack, is it possible?

I have the class Invoice that belongs_to Invoiceable, a polymorphic class. The Invoiceable of Invoice can either be Subscription or Purchase.

I need to be able to search by the status of an Invoice's Subscription or Purchase.

I'm trying the following to no success:

<%= f.check_box :invoiceable_of_Subscription_or_Purchase_type_status_in, { multiple: true }, type[1], false %>

I tried different combinations like:

<%= f.check_box :invoiceable_of_Subscription_type_or_invoiceable_of_Purchase_type_status_in, { multiple: true }, type[1], false %>

But I always get a Polymorphic associations do not support computing the class. error.

Is this possible? Ransack documentation only explains how to search by a single polymorphic associated model.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You were very close to the answer.

You need to specify column name with each of the polymorphic association

use below combination :

<%= f.check_box :invoiceable_of_Subscription_type_status_or_invoiceable_of_Purchase_type_status_in, { multiple: true }, type[1], false %>

Reference : https://github.com/activerecord-hackery/ransack/wiki/Polymorphic-searches

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda