Topic: Polymorphic associations on the belongs_to side
In my continual quest to build an e-commerce site for a record label, I have discovered that some products will belong to artists, but some products will simply belong to the record label. How shall I route this? Following REST convention, the most logical routes would seem to be:
/categories/1/products/1 (for record label's producs)
/categories/1/artists/1/products/2 (for artists' products)
Now I know that polymorphic associations facilitate has_many :whatevers, but how would I accomplish (a product) belongs_to :whatever (a category :through an artist, or directly to a category).
Also, routing becomes an issue, as the route for the products controller would be looking an artist_id in the param hash, and it wouldn't be there when pulling one of the record label's products.