2016-03-28 33 views
2

我無法檢索auditable_type的子表記錄關聯審計,因爲它總是給出父表類名稱。SIT in rails for audited-activerecord

我:

class Patient < ActiveRecord::Base 
has_many :diseases 
has_associated_audits 
end 

class Disease < MedicalHistory 
belongs_to :patient 
audited associated_with :patient 
end 

class MedicalHistory < ActiveRecord::Base 
end 

當我提出Patient.last.associated_audits.last.auditable_type給MedicalHistory,而不是疾病。

請讓我知道盡快。

+1

如果刪除ASAP,那就太好了。我們的堆棧將始終如一地幫助您 – Jaswinder

+0

如果您訪問gem的站點,您將不會發現提及單表繼承功能。你聲稱的是「不工作」我會假設維護者/管理員不會做廣告的功能。它是開源軟件,您應該考慮分叉庫並製作它以滿足您的需求。 – Tass

回答

1

是的,這是一個在這個寶石的問題。

但是你可以先檢索審計記錄,然後找出像它的類名:

Patient.last.associated_audits.last.auditable.class.name 

其實,在單個表繼承(STI)的每條記錄都有一個唯一的ID,這樣就可以使用標識記錄來自父類的記錄標識爲MedicalHistory.find(child_id)