title: Rails 4 using Proc.new with conditions inside active record association
body: <p>I created this association back when the project was using Rails 3. Since this we have upgraded to Rails 4 and now I am getting a deprecation warning about this. The following code is an example of what Rails 4 is saying is deprecated.</p>
  
  <pre><code>has_one :original_participant,
    :through =&gt; :original_participation,
    :source =&gt; :participants,
    :conditions =&gt; Proc.new {
      unless self.respond_to?(:organization_id)
        "original_participants_surveys_participants.organization_id = surveys_participants.organization_id"
      else
        "surveys_participants.organization_id = #{self.organization_id}"
      end
    }
  </code></pre>
  
  <p>The reason why the code has the unless condition inside the conditions block is due to sphinx. When sphinx is building it's indexes it will not have the organization_id available. When using the standard Active Record call it will have the organization_id. So I need to make this work both when it does and does not have the organization_id defined. I have done some research on this and so far have not come up with any solution for doing this the Rails 4 way. This still works fine in Rails 4 but again I keep getting the deprecation warning.</p>
  
  <p>Long question short how do I convert this to be Rails 4 compatible without loosing the ability to check if organization_id is available?</p>
  
  <p>Here is the actual warning message rails is giving me</p>
  
  <p>DEPRECATION WARNING: The following options in your Surveys::Participant.has_one :original_participant declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:</p>
  
  <pre><code>has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
  </code></pre>
  
  <p>should be rewritten as the following:</p>
  
  <pre><code>has_many :spam_comments, -&gt; { where spam: true }, class_name: 'Comment'
  </code></pre>