PostgreSQL
 SQL >> Database >  >> RDS >> PostgreSQL

Usare join con associazioni dal nome personalizzato in Rails

where si aspetta il nome reale della tabella, quindi puoi scrivere Measurement.joins(:examination).where(test_structures: { year: 2016 }).

Non è però ideale perché lega il codice al nome tabella. Meglio usare merge con una relazione ActiveRecord:

Measurement.joins(:examination).merge(TestStructure.where(year: 2016, month: 5))