# Help with modeling a problem (ActiveRecord)

**URL:** <https://www.ruby-forum.com/t/help-with-modeling-a-problem-activerecord/106958>\
**Category:** Rails\
**Created:** [June 15, 2007, 7:04pm UTC](https://www.ruby-forum.com/t/help-with-modeling-a-problem-activerecord/106958 "2007-06-15T19:04:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![emmanueloga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@emmanueloga](https://www.ruby-forum.com/u/emmanueloga)\
**Post date:** [June 15, 2007, 7:04pm UTC](https://www.ruby-forum.com/t/help-with-modeling-a-problem-activerecord/106958/1 "2007-06-15T19:04:54Z")

</div>

Hi! I need help with modeling my models 🙂

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!

---

<div class="post-metadata">

**Author:** ![emmanueloga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@emmanueloga](https://www.ruby-forum.com/u/emmanueloga)\
**Post date:** [June 15, 2007, 10:16pm UTC](https://www.ruby-forum.com/t/help-with-modeling-a-problem-activerecord/106958/2 "2007-06-15T22:16:15Z")

</div>

Anyone?

---

<div class="post-metadata">

**Author:** ![emmanueloga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@emmanueloga](https://www.ruby-forum.com/u/emmanueloga)\
**Post date:** [June 16, 2007, 4:21am UTC](https://www.ruby-forum.com/t/help-with-modeling-a-problem-activerecord/106958/3 "2007-06-16T04:21:44Z")

</div>

Emmanuel O. wrote:

> Anyone?

Someone?
