I am building an ecommerce site that will support pretty complex (and
very different) products. However, there are major portions that will
remain constant (such as associating with a store front-end,
categories, etc) so I don't want to have to remake those pieces of
functionality for each type of Product.
As an example, I am working with Goods (Product subtype that carries
inventory and varients) and Imports (Product subtype that is completely
customized to be ordered and imported from overseas). Here is what I
have figured out as far as the structure.
For a Good with ID => 1 I would have these resources
And for Import of ID => 2 I would have
I think that will work, although linking between these scenarios
becomes problematic as the return from product_stores would need to go
to either goods/1 or imports/1. I would rather not have a conditional
coded into each link as there will be more product types in the future
(and it would not be DRY, etc).
I tried to make a helper that would correctly route based on the
product type, but it would not work with arguments.
eval(@product[:type].underscore+'_path) # it generated the path
This did not work:
eval(@product[:type].underscore+'_path(:id =>1)') #tried other
variations as well
So, I'm completely stumped. Either I need to rethink my design pattern
for my resources or I need to figure out how to dynamically call
Any help would be extremely appreciated, I've been staring at this
problem for the past few days.