# Model Associations (is this OK?)

**URL:** <https://www.ruby-forum.com/t/model-associations-is-this-ok/147220>\
**Category:** Rails\
**Created:** [August 29, 2008, 2:20pm UTC](https://www.ruby-forum.com/t/model-associations-is-this-ok/147220 "2008-08-29T14:20:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![noddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ac8455/32.png) [@noddy](https://www.ruby-forum.com/u/noddy)\
**Post date:** [August 29, 2008, 2:20pm UTC](https://www.ruby-forum.com/t/model-associations-is-this-ok/147220/1 "2008-08-29T14:20:09Z")

</div>

Not wishing to start out on the wrong foot in the world of RoR, I would  
be grateful if someone could advise me if the following setup would be  
considered best practice or could it be improved upon.

I have five models:

User  
Customer  
Shop  
Supplier  
Quote

A user can sign up as a customer, shop or supplier. I’ve gone for a  
‘skinny’ user table and have created belongs\_to/has\_many associations to  
the different types of users (via user\_id in their respective tables).

A new quote will be created by a customer, the quote will then need to  
be accessed by the shop, who will update it, and then the supplier who  
will also update it. Do I now just need a quote table with customer\_id,  
shop\_id, supplier\_id and their respective belongs\_to/has\_many  
associations, or is there a more preferred solution?

Thanks

---

<div class="post-metadata">

**Author:** ![noddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ac8455/32.png) [@noddy](https://www.ruby-forum.com/u/noddy)\
**Post date:** [August 29, 2008, 2:40pm UTC](https://www.ruby-forum.com/t/model-associations-is-this-ok/147220/2 "2008-08-29T14:40:05Z")

</div>

Hi, you might want to look into creating a polymorphic association  
because  
Customer and Supplier are different types of a User. Also, a Shop is a  
place of business and a Quote is an estimated price for a service.  
Please  
check the following link:  
Optimizing aggregate counts of has\_many\_polymorphs in Rails: Part  
I[http://erolfornoles.wordpress.com/2008/08/10/optimizing-aggregate-counts-of-has\_many\_polymorphs-in-rails-part-i/](http://erolfornoles.wordpress.com/2008/08/10/optimizing-aggregate-counts-of-has_many_polymorphs-in-rails-part-i/)

Good luck,

-Conrad
