title: Rails 4 self-join adding where method to has_many causes errors
body: <p>I would like to create a self-join that includes a <code>where</code> method filter.</p>
  
  <p>To do so, I added <code>, -&gt; { where location_type: 'Hospital' }</code> to the Model:</p>
  
  <pre><code>class Location &lt; ActiveRecord::Base
  
    has_many :hospitals, class_name: "Location", foreign_key: "parent_id", -&gt; { where location_type: 'Hospital' }
    belongs_to :system, class_name: "Location", foreign_key: "parent_id"
  
  end
  </code></pre>
  
  <p>Unfortunately, this generates an error in the Rails Console:</p>
  
  <pre><code>2.0.0-p0 :001 &gt; x = Location.find_by_id(1353)
  SyntaxError: /Users/craibuc/Dropbox/Projects/Rails4/emr/app/models/location.rb:3: syntax error, unexpected '\n', expecting =&gt;
      from /Users/craibuc/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in `load'
      from /Users/craibuc/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in `block in load_file'
      from /Users/craibuc/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in `new_constants_in'
      from /Users/craibuc/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:422:in `load_file'
      from /Users/craibuc/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:323:in `require_or_load'
      from /Users/craibuc/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:in `load_missing_constant'
      from /Users/craibuc/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:in `const_missing'
      from (irb):1
      from /Users/craibuc/.rvm/gems/ruby-2.0.0-p0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
      from /Users/craibuc/.rvm/gems/ruby-2.0.0-p0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
      from /Users/craibuc/.rvm/gems/ruby-2.0.0-p0/gems/railties-4.0.0/lib/rails/commands.rb:64:in `&lt;top (required)&gt;'
      from bin/rails:4:in `require'
      from bin/rails:4:in `&lt;main&gt;'
  </code></pre>
  
  <p>The <a href="http://edgeguides.rubyonrails.org/association_basics.html#has-many-association-reference" rel="nofollow">documentation</a> indicates that a <code>where</code> clause is support for a <code>has_many</code>, perhaps it isn't supported for self-joins.  Can anyone confirm this?  Is there another approach?</p>