rails/rails — pull request #11130 by Empact (2013-06-26 20:56:58+00:00)
Title: Fix that CollectionProxy#scoping was failing to set #proxy_association for the returned scope.

This meant that #proxy_association would be nil if your association
extension methods were called atop a named scope.

With the change we rely on CollectionProxy's own definition of #scope,
which properly sets #proxy_association.

More evidence here: https://gist.github.com/Empact/5865483
```
Active Record 3.2.13
-- create_table(:users, {:force=>true})
-> 0.1359s
-- create_table(:logins, {:force=>true})
-> 0.0004s
Bob has 0 logins
Bob has 0 logins
```

```
Active Record 4.0.0
-- create_table(:users, {:force=>true})
-> 0.1610s
-- create_table(:logins, {:force=>true})
-> 0.0004s
Bob has 0 logins
./proof.rb:37:in `announce': undefined method `owner' for nil:NilClass (NoMethodError)
from ./proof.rb:44:in `

'
```

This was previously open as #10990