基于has_one关系的Rails查询

问题描述 投票:0回答:1
class Hospital
 has_many: invoice_transaction, through: :invoices
 has_many: invoices
end 

class invoice
 belongs_to :hospital
end 

class InvoiceTransaction      
  belongs_to: invoice 
  has_one :hospital, through: :invoice
end 





hospital.invoice_transactions works well

现在我想基于多个医院ID查询[C0

类似这样的东西

InvoiceTransaction

但是这将返回空记录

ruby-on-rails activerecord associations
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.