Help with modeling a problem (ActiveRecord)

Hi! I need help with modeling my models :slight_smile:

This is the situation:


I need to manage record on product failures. I have three distinct
features on the products:

  1. ProductName: id, description
  2. ProductFormat: id, description, width, height
  3. ProductThickness: id, description

Now, i will form Products as combination of the former features:

  1. Product: id, ProductName id, ProductFormat id,
    ProductThickness id,
    usages

The table 4, as i see it, is kind of a join table, but is also a model
because of the “usages” field, am i right? So i think I should make the
following relations on the models:

ProductName < ActiveRecord::Base
has_many :product_thicknesses, :trough => :products
has_many :product_formats, :trough => :products
end

ProductFormat < ActiveRecord::Base
has_many :product_thicknesses, :trough => :products
has_many :product_names, :trough => :products
end

ProductThickness < ActiveRecord::Base
has_many :product_formats, :trough => :products
has_many :product_names, :trough => :products
end

Product < ActiveRecord::Base
belongs_to :product_thicknesses
belongs_to :product_formats
belongs_to :product_names
end

Is this correct? Is there any better form?


Also, i’m trying to build a restfull interface to my products, as to
identify them as this given url’s

product_name/#id/product_format/#id/product_thicness/#id

This would be right if i think on combination of features, but truth is
not all the combinations are allowed, only those listed on the products
table, that happens to have an id beacuse is not only a join table but
also saves information about the 3 features combination…

What do you think???

Very Thanks!

Anyone?

Emmanuel O. wrote:

Anyone?

Someone?