title: Silblings in has_many relationship
body: <p>A user has many employments. </p>
  
  <p>What do you think? 
  Is this a valid and clear way to fetch all siblings (belonging to the same user) of a given employment object?</p>
  
  <pre><code>class Employment &lt; ActiveRecord::Base
    belongs_to :user
  
    has_many :silblings,
      :primary_key =&gt; :user_id,
      :foreign_key =&gt; :user_id,
      :class_name =&gt; 'Employment'
  end
  </code></pre>
  
  <p>This can be extended with the following named scope:</p>
  
  <pre><code>  named_scope :except, lambda {|id| {:conditions =&gt; ["id != ?", id]} if id}
  </code></pre>
  
  <p>Now I can do stuff like:</p>
  
  <pre><code>  self.silblings.except(self.id).each do |silbling|
      puts silbling
    end
  </code></pre>
  
  <p>The resulting SQL statement looks like: </p>
  
  <pre><code>  SELECT * FROM `employments` 
    WHERE (`employments`.user_id = 49) 
    AND ((id != 46) AND (`employments`.user_id = 49))
  </code></pre>
  
  <p>Comments like 'no, you abuse XY, rather use this XZ' are very welcome!</p>
  
  <p>Reto </p>