I have the following entities:
Product, Supplier. Manufacturer < Supplier and Vendor < Supplier.
Product has_many suppliers through products_suppliers
The thing is, the type of the supplier will depend on the product – this is the requirement. So, that’s why I though the type information should be in the products_suppliers entity.
What I would like to happen is, when a supplier is retrieved using the following command:
@suppliers = @product.suppliers.all
Somehow hook up AR and look into the type attribute of the products_suppliers association and for each record, instantiate the correct class (either Vendor or Manufacturer).
It’s STI, only that the type data is in another realm and is “variable” (depending on the product).
Is there a way to do that with the current STI implementation in Rails 2.2.2? If not, how could I hook up AR to make it happen? Or do you suggest something simpler?
Any suggestions appreciated.