简体   繁体   中英

Rails 3. ActiveAdmin filter for child association

I have shipments has one invoice; and invoice belongs to shipments. When I try to do this...

filter :customer, :collection => proc {(Customer.all).map{|c| [c.company_name, c.id]}}

O get this error (Mysql::Error: Unknown column 'invoices.customer_id' .

The customer_id column is actually on the shipments table. Since invoice belongs to shipment, I usually access the customer_id by doing invoice.shipment.customer_id . But I don't know how to implement this to create an activeadmin filter.

Complete error: SQLite3::SQLException: no such column: invoices.customer_id: SELECT COUNT(DISTINCT count_column) FROM (SELECT "invoices"."id" AS count_column FROM "invoices" LEFT OUTER JOIN "customers" ON "customers"."id" = "invoices"."customer_id" LEFT OUTER JOIN "shipments" ON "shipments"."id" = "invoices"."shipment_id" WHERE "customers"."id" = 2 LIMIT 30 OFFSET 0) subquery_for_count

您可以使用嵌套属性吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM