title: Rails has_one vs belongs_to semantics
body: <p>I have a model representing a <code>Content</code> item that contains some images. The number of images are fixed as these image references are very specific to the content. For example, the <code>Content</code> model refers to the <code>Image</code> model twice (profile image, and background image). I am trying to avoid a generic <code>has_many</code>, and sticking to multiple <code>has_one</code>'s. The current database structure looks like:</p>
  
  <pre><code>contents
    - id:integer
    - integer:profile_image_id
    - integer:background_image_id
  
  images
    - integer:id
    - string:filename
    - integer:content_id
  </code></pre>
  
  <p>I just can't figure out how to setup the associations correctly here. The <code>Content</code> model could contain two <code>belongs_to</code> references to an <code>Image</code>, but that doesn't seem semantically right cause ideally an image belongs to the content, or in other words, the content has two images.</p>
  
  <p>This is the best I could think of (by breaking the semantics):</p>
  
  <pre><code>class Content
    belongs_to :profile_image, :class_name =&gt; 'Image', :foreign_key =&gt; 'profile_image_id'
    belongs_to :background_image, :class_name =&gt; 'Image', :foreign_key =&gt; 'background_image_id'
  end
  </code></pre>
  
  <p>Am I way off, and there a better way to achieve this association?</p>