J. Riddel wrote:
I'm working on a simple product catalog. Products have user defined
attributes, such as: color, size, weight. More attributes can be added
at any time. Since these attributes are not known ahead of time, they
cannot be created as columns.
Let me suggest I a plugin I have created for this purpose.
The plugin is still in "beta" since the application it is made for has not been rolled out to production but it seems to work well.
Basically your model looks something like:
class Product < ActiveRecord::Base
Then you can just add/remove attributes as you need. If the attribute exists on the model it will be stored there. If it does not then it will be stored in a "thin" table called product_attributes.
There are also hooks so you can define what attributes are valid. Finally the plugin works with acts_as_versioned/acts_as_versioned_association.
The docs are a little scattered right now because the product it was created for is still in development but you are welcome to use what I have.