Reputation: 447
I am new to ruby on rails. I am working on a database where there exists different types of products and each type has many specialized products.
So for example, producttype has two attributes: "manufacturer" and "designer" (there is no name attribute for producttype) and for specialized ones we have for example product1 with attributes as : "manufacturer", "designer" , "facilitator", "carrier"
So in fact products inherit the two attributes from producttypes and specify others. I want to record the products in different stores and for that I want to be able to auto-complete when entering in the manufacturer field in the corresponding form page of a product (auto-complete based on the possible values for manufacturer in the table of producttypes). To make this possible, is it better to define "manufacturer" as a model or having it as an attribute is fine?
Upvotes: 1
Views: 34
Reputation: 1136
If "manufacturer" is unique to each "product_type", then it should be an attribute. Otherwise, it should be a model on its own, especially if you intend to add more "manufacturers" along the way.
Models should be designed based on real life "objects", not to UI needs. If the UI needs something very special, you can add it on later.
Upvotes: 0