Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

692
Views
Búsqueda de asociaciones polimórficas múltiples usando Ransack, ¿es posible?

Tengo la clase Invoice que belongs_to Invoiceable , una clase polimórfica. El Invoiceable de Factura puede ser Subscription o Purchase .

Necesito poder buscar por estado de Subscription o Purchase de una Factura.

Estoy intentando lo siguiente sin éxito:

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

Probé diferentes combinaciones como:

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

Pero siempre obtengo Polymorphic associations do not support computing the class. error.

es posible? La documentación de Ransack solo explica cómo buscar por un solo modelo polimórfico asociado.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Estuviste muy cerca de la respuesta.

Debe especificar el nombre de la columna con cada una de las asociaciones polimórficas

use la siguiente combinación:

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

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

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!