Hi all,
I wondered if the following is implemented in ActiveRecord:
I have three tables: “products”, “properties” and “product_properties”
the products table holds base information for the product, like
product_id, name etc.
Product.column_names
=> [“product_id”, “name”]
the properties table holds extra “columns” for the products table, but
the column “name” in this table should actually be a method for
Products
Property.column_names
=> [“property_id”, “name”, “description”, “position”]
the third table product_properties holds the mapping data between
products and properties
ProductProperty.column_names
=> [ “product_property_id”, “product_id”, “property_id”, “value”]
If I do this:
Property.create(:name => ‘color’)
I would like to be able to do:
Product.create(:name => “Glass”, :color => “transparent”)
and
Product.find(:all, :conditions => [“color=?”,“transparent”])
or
Product.color
=> “transparent”
or
Product.color = “red”
where saving/retrieving the “color” method saves/retrieves the values
to/from ProductProperties.
Is this possible, and if not what is the best place to start coding?
–
Sincerely,
Frodo L.