Topic: Design of a Advertisement (inheritance? associations?)
I'm designing what amounts to a Classified Advertisment RoR application, and I could really use some help figuring out how to design my models and associations to represent my data.
Essentially, I need to have ads of different types have different fields to specify information specific for that type. For example, a Horse might have a color and breed, while a piece of tack would have a style (english or western). Additionally, I'd like to have sub-types like a saddle, which would have the attributues of a piece of tack as well as a size.
As if that wasn't enough, I'll need to be able to search by the attributues (find all brown horses, find english saddles size 15 or larger)
Options I see for doign this are:
1) Single Table Inheritance with an Advert Model and then a type field and sublassed models. This seems like it would make searching easy, but doesn't seem to scale very well as we develop more and more ad types.
2) Have an Advert model that has a type field and has_many Attributes. An attribute would have a label and a value.
3) Have an Advert model that has a type field and has_one advert_description through a polymorphic associations. The models that are advert descriptions would have a set of fields to describe a particular advert.
Can anyone offer me any suggestions on which option they think makes the most sense or what other options I may not have considered?