I'm working on my first Rails application (my first Ruby app, for that matter) and I have a best practice question about inheritance. I have to be able to upload physical media and I want to store the physical properties separately in the database so that certain attributes can be queried outside of the application as easily as within in. To manage this, I have an images table and a binaries table. The former stores metadata specific to images, of course, while the latter stores physical file metadata that will apply to a range of file types. Once I have my approach solidified, I'll add a swfs table, a videos table and perhaps others.
At the moment, I have a BinaryObserver class captures the before_create callback of an image and uploads the physical file - the binary. This is working fine, but I'm wondering about other approaches. Specifically, I'm wondering if I couldn't (and shouldn't) establish a basic inheritance model where Binary extends ActiveRecord::Base and Image extends Binary.
As it stands right now, Image belongs_to Binary and Binary has_one Image. Since there's an obvious is-a relationship, though, should I use inheritance? Does rails even support such a thing when interacting with a database? This might be the best way to reduce the amount of work required to support a new file type.
Would appreciate any thoughts or suggestions on this. I'm experimenting with the language and the framework, so I'm trying to learn best practices before I get in too deep.
Thanks.