# 3 models -\> 1 image

**URL:** <https://www.ruby-forum.com/t/3-models-1-image/57895>\
**Category:** Rails\
**Created:** [April 15, 2006, 8:31pm UTC](https://www.ruby-forum.com/t/3-models-1-image/57895 "2006-04-15T20:31:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/65b543/32.png) [@nuno](https://www.ruby-forum.com/u/nuno)\
**Post date:** [April 15, 2006, 8:31pm UTC](https://www.ruby-forum.com/t/3-models-1-image/57895/1 "2006-04-15T20:31:30Z")

</div>

Hello, I have 3 models (Galery, Product, News) which all have 0 or 1  
Image

I don’t understand what the relationship between the 3 models and the  
Image model should be.

I might goes to Galery has\_one Image, Product has\_one Image and News  
has\_one Image but I presume that active record will rely on Image model  
having a foreign key related to only one owner model (eg.  
Image.galery\_id), which can’t be the case.

Any hint appreciated, thank you

---

<div class="post-metadata">

**Author:** ![nuno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/65b543/32.png) [@nuno](https://www.ruby-forum.com/u/nuno)\
**Post date:** [April 15, 2006, 8:58pm UTC](https://www.ruby-forum.com/t/3-models-1-image/57895/2 "2006-04-15T20:58:09Z")

</div>

How about having your Gallery, Product, and News belongs\_to Image?

---

<div class="post-metadata">

**Author:** ![nuno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/65b543/32.png) [@nuno](https://www.ruby-forum.com/u/nuno)\
**Post date:** [April 15, 2006, 10:55pm UTC](https://www.ruby-forum.com/t/3-models-1-image/57895/3 "2006-04-15T22:55:34Z")

</div>

Doesn’t sound natural for me…

I’ve found this thread ([http://www.ruby-forum.com/topic/61327](http://www.ruby-forum.com/topic/61327)) and the  
last answer close to my feelings about belongs\_to.

I don’t know if this solution is the right one.

Any thought about this ?
