# Relationships in Rails

**URL:** <https://www.ruby-forum.com/t/relationships-in-rails/126598>\
**Category:** Rails\
**Created:** [January 20, 2008, 3:51am UTC](https://www.ruby-forum.com/t/relationships-in-rails/126598 "2008-01-20T03:51:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimmypalmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jimmypalmer](https://www.ruby-forum.com/u/jimmypalmer)\
**Post date:** [January 20, 2008, 3:51am UTC](https://www.ruby-forum.com/t/relationships-in-rails/126598/1 "2008-01-20T03:51:10Z")

</div>

I understand basic relationships in rails, but I’m confused on how to  
solve a particular problem.

I have posts and products. Both of which should be able to have  
multiple photos uploaded to them. So, posts have many photos and photos  
belongs to posts - BUT products have many photos too and photos belongs  
to products.

Products and posts have no relationship but they share the same child.

Is there a clean (non-hack) sort of way to solve this in Rails without  
creating a bunch of extra classes.
