class Upload < ActiveRecord::Base
has_many :comments
end
class Gallery < Upload
has_many :images
end
class MusicAlbum < Upload
has_many :audio_tracks
end
Should this work as expected? Will Gallery and MusicAlubm models inherit :comments association from their parent (Upload) and add their own?
Yes, the models are just classes, and when inherited they get all the methods from parent class. So, as both
GalleryandMusicAlbumare descendants fromUploadmodel, they will have thehas_many :commentsassociation, and both will get data fromuploadsdb table (which needs to have atypecolumn to support STI for this model)A nice simple STI example can be found here