title: Validate that belongs_to is in allowed values
body: <p>I have this structure</p>
  
  <pre><code>class Organization
    has_many :clients
  end
  
  class Client
    belongs_to :organization
    has_many :contacts
  end
  
  class Contact
    belongs_to :client
    belongs_to :organization
  end
  </code></pre>
  
  <p>How can I make sure that when client is assigned to a contact he is a child of a specific organization and not allow a client from another organization to be assigned ? </p>
  
  <p>While searching I did find a <code>scope</code> parameter can be added but that seems not to be evaluated when <code>client_id</code> is assigned.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is an example from Rails Docs :</p>
  
  <pre><code>validates :name, uniqueness: { scope: :year,message: "should happen once per year" }
  </code></pre>
  
  <p>I'm looking for something like "if client is set it must be in Organization.clients"</p>