class Upload < ActiveRecord::Base
has_many :comments
end
class Gallery < Upload
has_many :images
end
class MusicAlbum < Upload
has_many :audio_tracks
end
應該按預期工作嗎?將Gallery和MusicAlubm模型繼承:來自其父級的評論關聯(Upload)並添加自己的?Rails STI - 子類中的自定義關聯
聲明基類中所有關聯的一個原因是能夠在加載上載時急切加載所有關聯。換句話說,我可以做'''Upload.all include:[:comments,:images,:audio_tracks]''' –